This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from collections import namedtuple | |
| from pymongo import MongoClient | |
| from flask import request | |
| from core.web.site import app | |
| from core.web.site.views_master import * | |
| import json | |
| ''' | |
| $('#companies').dataTable( { | |
| "bProcessing": true, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This is a really old post, in the comments (and stackoverflow too) you'll find better solutions. | |
| def find(key, dictionary): | |
| for k, v in dictionary.iteritems(): | |
| if k == key: | |
| yield v | |
| elif isinstance(v, dict): | |
| for result in find(key, v): | |
| yield result | |
| elif isinstance(v, list): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # to generate your dhparam.pem file, run in the terminal | |
| openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Склонение существительных | |
| * Правильная форма cуществительного рядом с числом (счетная форма). | |
| * | |
| * @example declension("файл", "файлов", "файла", 0);//returns "файлов" | |
| * @example declension("файл", "файлов", "файла", 1);//returns "файл" | |
| * @example declension("файл", "файлов", "файла", 2);//returns "файла" | |
| * | |
| * @param {string} oneNominative единственное число (именительный падеж) | |
| * @param {string} severalGenitive множественное число (родительный падеж) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var mysql = require('mysql') | |
| , bcrypt = require('bcrypt') | |
| , db = { | |
| host: 'localhost', | |
| user: 'root', | |
| database: 'prod' | |
| }; | |
| function checkUser(email, password, callback) { | |
| var connection = mysql.createConnection(db); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import base64 | |
| from django.core.files.base import ContentFile | |
| from rest_framework import serializers | |
| class Base64ImageField(serializers.ImageField): | |
| def from_native(self, data): | |
| if isinstance(data, basestring) and data.startswith('data:image'): | |
| # base64 encoded image - decode |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var WebSocketServer = require('ws').Server; | |
| var wss = new WebSocketServer({port: 8080}); | |
| var jwt = require('jsonwebtoken'); | |
| /** | |
| The way I like to work with 'ws' is to convert everything to an event if possible. | |
| **/ | |
| function toEvent (message) { | |
| try { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Script generated Fri Jan 24 17:06:34 ART 2014 by root(0) | |
| check process gearman.worker.user.user_registration with pidfile "/var/run/gearman.worker.user.user_registration.pid" | |
| start program "/bin/bash -c '/home/dario/.phpbrew/php/php-5.4.23/bin/php /home/dario/Playground/sm/public/index.php gearman worker execute user.user_registration >> /tmp/gearman.worker.user.user_registration.log & echo $! > /var/run/gearman.worker.user.user_registration.pid'" | |
| stop program "/usr/bin/pkill --full user.user_registration" | |
| check process gearman.worker.user.user_invitation with pidfile "/var/run/gearman.worker.user.user_invitation.pid" | |
| start program "/bin/bash -c '/home/dario/.phpbrew/php/php-5.4.23/bin/php /home/dario/Playground/sm/public/index.php gearman worker execute user.user_invitation >> /tmp/gearman.worker.user.user_invitation.log & echo $! > /var/run/gearman.worker.user.user_invitation.pid'" | |
| stop program "/usr/bin/pkill --full user.user_invitation" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| celery flower --address=127.0.0.1 --url_prefix=flower --broker=<broker url> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # Backup linux server via rsync to remote backup NAS drive | |
| # | |
| # Run this from a root cronjob at whatever intervals you need | |
| # | |
| # example: | |
| # # backup server at 4am | |
| # 0 4 * * * sh /root/rsync_server_backup.sh > /dev/null; | |
| # |