Skip to content

Instantly share code, notes, and snippets.

View dayatz's full-sized avatar

Bahrul Hidayat dayatz

  • Mataram, Indonesia
View GitHub Profile
@dayatz
dayatz / celery-beat-appcom.conf
Created March 28, 2020 06:59 — forked from nmfzone/celery-beat-appcom.conf
Django Production Configuration using Supervisor + Gunicorn + Celery + Flower + Pyenv Virtualenv
########## DO NOT INCLUDE THIS ##########
# File Location: /etc/supervisor/conf.d/celery-beat-appcom.conf
#########################################
[program:celery_beat_appcom]
process_name=%(program_name)s
command=/home/johndoe/django-app/celery-beat/run-appcom-celery-beat.sh
startsecs=10
autostart=true
autorestart=true
def prepare_order_request_data(self, order: order_models.Order) -> Any:
agent_application = order.agent_application_id
items = list(order.item_set.all())
express_type = '1' # Standard Express
order_declared_value = 0
for item in items:
us_converted_item_price_value = round(backend_utils.currency_conversion(
item.item_price_currency,
def calculate_dw_at_dl(dw, dl):
lbs = (dw/20.0) * abs(dl-28)
if dl < 28:
return dw - lbs
return lbs + dw
def calculate_dw_at_dl(dw, dl):
lbs = (dw/20.0) * abs(dl-28)
if dl < 28:
return dw - lbs
return lbs + dw
@dayatz
dayatz / controller
Created August 10, 2016 22:39
Upload and show images in Sails JS
req.file('image').upload({
dirname: '../../assets/images/'
}, function(error, uploadedFiles) {
// do something after file was uploaded...
});
---------------------------------------------------------------
// save original file name
req.file('image').upload({
saveAs: function(file, cb) {
class DynamicFieldsSerializer(object):
"""
serializer = UserSerializer(fields=['your', 'fields', 'here'])
-- or --
serializer = UserSerializer(remove_fields=['field', 'to', 'remove'])
"""
def __init__(self, *args, **kwargs):
@dayatz
dayatz / checkPacktubFree.js
Created June 7, 2015 12:53
Check Packtub free offers today
var scrap = require('scrap');
scrap('https://www.packtpub.com/packt/offers/free-learning', function(err, $){
console.log($('.dotd-title h2').text().trim());
});
// in html
<i id="dayatIcon" class="ion-female" to='ion-male'></i>
// create new js file, and include to your html
isAnimating = false;
function dayatIcon(anim){
$(document).on('mouseenter', '#dayatIcon', function(){
var e = $(this);
if (isAnimating) return;
@dayatz
dayatz / index.js
Last active August 29, 2015 14:19 — forked from jfensign/index.js
//index.js
var express = require('express'),
app = module.exports = express.createServer(),
mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/nodeAuth');
//configure app
app.configure(function() {
app.set('views', __dirname + '/views');

What is your folder-structure preference for a large-scale Node.js project?

0: Starting from Rails

This is the reference point. All the other options are based off this.

|-- app
|   |-- controllers
|   |   |-- admin