Skip to content

Instantly share code, notes, and snippets.

View ustun's full-sized avatar

Ustun Ozgur ustun

View GitHub Profile
{
"env": {
"browser": true,
"es6": true,
"node": true
},
"ecmaFeatures": {
"arrowFunctions": true,
"blockBindings": true,
"classes": true,
@ustun
ustun / index.js
Created January 12, 2016 23:25
requirebin sketch
var deasciifier = require('turkish-deasciifier');
var deascii = new deasciifier();
console.log(deascii.deasciify("Turkce guzel bir dildir."));
@ustun
ustun / eslint-auto.el
Created January 12, 2016 23:59
run eslint --fix on emacs file save
;;; runs eslint --fix on the current file after save
;;; alpha quality -- use at your own risk
(defun eslint-fix-file ()
(interactive)
(message "eslint --fixing the file" (buffer-file-name))
(shell-command (concat "eslint --fix " (buffer-file-name))))
(defun eslint-fix-file-and-revert ()
(interactive)
Some Notes on Django and Celery Logging:
1. logging_tree is very useful. logging_tree.print_output()
2. Celery by defaults hijacks the logger, and overwrites its handler and formatter.
You can set it to not hijack, in which case the root logger will be preserved, except for its level.
The level of the root logger is still hijacked by the celery process.
3. Django has its own default logging, which is merged with our logging. To disable old logging,
class DatabaseLoggingMiddleware(object):
def process_request(self, request):
request.start_time = time.time()
def process_response(self, request, response):
if 'content-type' in response._headers and response._headers['content-type'][1].startswith('application/json') and response.status_code == 200:
end_time = time.time()
total_execution_time_msec = int((end_time - request.start_time) * 1000)
[ignore]
.*/node_modules/fbjs/.*
.*/node_modules/flux/.*
.*/node_modules/npm/.*
.*/node_modules/babylon/.*
[options]
module.name_mapper='.*\(.less\)' -> 'empty/object'
module.name_mapper='.*\(.css\)' -> 'empty/object'
module.system.node.resolve_dirname=node_modules
@ustun
ustun / flow_func.js
Created August 16, 2016 18:15
Function type declaration for flowtype
//@flow
// define the function type
type FunctionThatTakesAStringAndReturnsANumber = (x: string) => number;
function higherOrderFunction(myFn: FunctionThatTakesAStringAndReturnsANumber) {
return "something";
}
@ustun
ustun / parse5spice.m
Created August 16, 2016 23:29
Parses (imports) 5Spice data to MATLAB
function parse5spice(filename)
% PARSE5SPICE Parses the data in the Report tab of the 5Spice software and
% imports it into MATLAB workspace
% Call the function with an optional filename. If no filename is specified,
% a data.txt in the same directory is used.
% To create data.txt, right click in 5Spice in the Report tab, click Select
% All, and Copy and paste into an empty file. Then, save data as data.txt
% in the same directory
ag '^[ \t]+from ' questions | grep -v django | grep -v vendor | grep -v 'from questions'
@ustun
ustun / matching_view_func_middleware.py
Created August 25, 2016 12:59
If the response is a json object, outputs the matched func, file name and line no
class MatchingViewFuncMiddleware(object):
def process_request(self, request):
pass
def process_response(self, request, response):
if 'content-type' in response._headers and \
response._headers['content-type'][1].startswith('application/json') and \
response.status_code == 200: