Skip to content

Instantly share code, notes, and snippets.

View psych0der's full-sized avatar

Mayank Bhola psych0der

View GitHub Profile
@psych0der
psych0der / fast-exponential.c
Created August 22, 2013 16:56
fast exponential calculation using repeated squaring
int expo(int a, int b){
int result = 1;
while (b)
{
if (b%2==1)
{
result *= a;
}
b /= 2;
@psych0der
psych0der / ftos.c
Created August 23, 2013 13:16
converting float to string without using library function like sprintf (naive approach , may lead to anomalies)
#include <stdio.h>
#include <math.h>
#define precision 6 //precision for decimal digits
int main(int argc, char const *argv[])
{
float f,ff;
@psych0der
psych0der / recursive-sol
Created September 24, 2013 16:05
recursive solution to series : 1+2*4 + 3*5*7 + 4*6*8*10 .....
int level,sol; //level of recusrsion
printf("Enter the level\n");
scanf("%d",&level);
sol = solve(1);
int solve(int n)
{
int temp=1;
for(int i=1;i<n+1;i++)
@psych0der
psych0der / psa_doubt
Created March 15, 2014 16:03
python social auth social information QA
hi psych0der
psych0der
hey cadillac_
psych0der
i am bit cofused about accessing info about user object which is created in request
cadillac_
the social info?
psych0der
yes
psych0der
@psych0der
psych0der / define.py
Created February 27, 2017 11:07 — forked from lambdamusic/define.py
Access osx dictionary in python
#!/usr/bin/env python
"""
Modified from
http://macscripter.net/viewtopic.php?id=26675
http://apple.stackexchange.com/questions/90040/look-up-a-word-in-dictionary-app-in-terminal
HowTo
@psych0der
psych0der / firebase_copy.js
Created May 5, 2017 04:19 — forked from katowulf/firebase_copy.js
Move or copy a Firebase path to a new location
function copyFbRecord(oldRef, newRef) {
oldRef.once('value', function(snap) {
newRef.set( snap.value(), function(error) {
if( error && typeof(console) !== 'undefined' && console.error ) { console.error(error); }
});
});
}
@psych0der
psych0der / ultimate-ut-cheat-sheet.md
Created September 21, 2017 08:23 — forked from yoavniran/ultimate-ut-cheat-sheet.md
The Ultimate Unit Testing Cheat-sheet For Mocha, Chai and Sinon

The Ultimate Unit Testing Cheat-sheet

For Mocha, Chai and Sinon

using mocha/chai/sinon for node.js unit-tests? check out my utility: mocha-stirrer to easily reuse test components and mock require dependencies


@psych0der
psych0der / sysctl.conf
Created February 19, 2018 09:54 — forked from Poorvak/sysctl.conf
Linux Web Server Kernel Tuning
# Configuration file for runtime kernel parameters.
# See sysctl.conf(5) for more information.
# See also http://www.nateware.com/linux-network-tuning-for-2013.html for
# an explanation about some of these parameters, and instructions for
# a few other tweaks outside this file.
# Protection from SYN flood attack.
net.ipv4.tcp_syncookies = 1
@psych0der
psych0der / fix_virtualenv
Created April 4, 2018 07:44 — forked from tevino/fix_virtualenv
Fix python virtualenv after python update
#!/usr/bin/env bash
ENV_PATH="$(dirname "$(dirname "$(which pip)")")"
SYSTEM_VIRTUALENV="$(which -a virtualenv|tail -1)"
echo "Ensure the root of current virtualenv:"
echo " $ENV_PATH"
read -p "‼️ Say no if you are not sure (y/N) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo "♻️ Removing old symbolic links......"
@psych0der
psych0der / start-celery-for-dev.py
Created April 14, 2018 04:33 — forked from chenjianjx/start-celery-for-dev.py
A python script which starts celery worker and auto reload it when any code change happens.
'''
A python script which starts celery worker and auto reload it when any code change happens.
I did this because Celery worker's "--autoreload" option seems not working for a lot of people.
'''
import time
from watchdog.observers import Observer ##pip install watchdog
from watchdog.events import PatternMatchingEventHandler
import psutil ##pip install psutil
import os