Skip to content

Instantly share code, notes, and snippets.

View kaushik94's full-sized avatar
🎉
Partying

Kaushik Varanasi kaushik94

🎉
Partying
View GitHub Profile

MacOS

Build 3059

MD5: 59bab8f71f8c096cd3f72cd73851515d

Rename it to: Sublime Text

Make it executable with: chmod u+x Sublime\ Text

@kaushik94
kaushik94 / montecarlo_thomson_scatter.c
Created June 17, 2015 16:38
montecarlo_thomson_scatter
void
montecarlo_thomson_scatter (rpacket_t * packet, storage_model_t * storage,
double distance)
{
double comov_energy, doppler_factor, comov_nu, inverse_doppler_factor;
doppler_factor = move_packet (packet, storage, distance);
comov_nu = rpacket_get_nu (packet) * doppler_factor;
comov_energy = rpacket_get_energy (packet) * doppler_factor;
rpacket_set_mu (packet, 2.0 * rk_double (&mt_state) - 1.0);
inverse_doppler_factor = 1.0 / rpacket_doppler_factor (packet, storage);
@kaushik94
kaushik94 / test_element_symbol_reformatter.py
Last active August 29, 2015 14:23
test_element_symbol_reformatter
def test_element_symbol_reformatter():
def _test_element_symbol_reformatter(
unformatted_element_string, formatted_element_string):
assert reformat_element_symbol(
unformatted_element_string) == formatted_element_string
data = [('si', 'Si'),
('sI', 'Si'),
('Si', 'Si'),
('c', 'C'),
@kaushik94
kaushik94 / test_element_symbol_reformatter.py
Last active August 29, 2015 14:23
test_element_symbol_reformatter
def test_element_symbol_reformatter():
def _test_element_symbol_reformatter(
unformatted_element_string, formatted_element_string):
assert reformat_element_symbol(
unformatted_element_string) != formatted_element_string
data = [('si', 'Si'),
('sI', 'Si'),
('Si', 'Si'),
('c', 'C'),
@kaushik94
kaushik94 / test_element_symbol_reformatter.py
Created June 17, 2015 17:02
test_element_symbol_reformatter
@pytest.mark.parametrize(
"unformatted_element_string, formatted_element_string", [
('si', 'Si'),
('sI', 'Si'),
('Si', 'Si'),
('c', 'C'),
('C', 'C'),
])
def test_element_symbol_reformatter(
unformatted_element_string, formatted_element_string):
@kaushik94
kaushik94 / dictionary.py
Created September 2, 2015 10:19
reversing a dictionary
def reverseDict(somedict):
newdict = {}
for each in somedict:
for one in somedict[each]:
newdict[one] = each
return newdict
something = {'Bob':['Harry','Jenkins', 'Onion', 'Fred', 'Earl', 'Sam'],
'Wayne':['Wallace', 'David', 'Eel', 'Perkins', 'Fruit', 'Angela'],
'Jeff':['Aaron', 'Cameron', 'Keith', 'Winston', 'Geoff', 'Wayne']
@kaushik94
kaushik94 / dejavu
Last active October 5, 2015 06:21
dejaVu
## The idea
The idea was to have a frontend for a streaming data of json documents and a way to notify of any updates/deletes. So technically we want the browser to do just one thing - update the frontend as new document comes in or if something changes and we wanted it to be good at just that.
## React ? Seriously ?
We chose react to build this since it deals well with one thing in particular - How to update the DOM from state A to state B in the most optimal way(less read/writes). You can control the DOM without exactly telling how to reach there, but just by telling what it should look like in an object-oriented fashion. Plus its a perfect library for frontend. Other options like angular and JQuery fall into the category of frameworks which let you manipulate the DOM "easily". This is sometimes bad since we just want the template to render the data in a particular fashion once we let it know what the data is. Refer to "Why so much code?" section for more detail.
## Ohh but ..
Note : that I am not talking
@kaushik94
kaushik94 / .bash_profile.sh
Created November 14, 2015 11:01
Make an alias in Bash shell in OSX terminal
# At the end of this file
alias <new-alias-without-quotes>='<existing-command-in-quotes>'
# Fork your repo example, the following is link to mine
https://github.com/kaushik94/privacybadgerchrome
# On your terminal
git clone https://github.com/kaushik94/privacybadgerchrome
# Install and run tests, then checkout another branch
# and name it in a way that resonates with the issue being solved
git checkout -b <new-branch-name-withou-these-brackets>
#!/usr/bin/env python2.7
from __future__ import print_function
import commands
import os
import stat
from gitlab import Gitlab
def get_clone_commands(token, repo_root):
con = Gitlab("http://gitlab.your.domain", token)