Skip to content

Instantly share code, notes, and snippets.

View BinRoot's full-sized avatar

Nishant Shukla BinRoot

View GitHub Profile
@Nurdok
Nurdok / python_conversion.md
Last active December 16, 2022 03:45
Python Conversion

Python Number Conversion Chart

From To Expression
@eranation
eranation / gist:3241616
Created August 2, 2012 22:51
MongoDB Aggregation Framework way for "select count (distinct fieldName) from someTable" for large collections
//equivalent of "select count (distinct fieldName) from someTable"
db.someCollection.aggregate([{ $group: { _id: "$fieldName"} },{ $group: { _id: 1, count: { $sum: 1 } } } ])
@jasdev
jasdev / gist:3205164
Created July 30, 2012 05:44
2 line wonder
private void RadiusPanel_Tap(object sender, System.Windows.Input.GestureEventArgs e)
{
settings["radius"] = ((int)settings["radius"] % 10) + 1;
radiusText.Text = (int)settings["radius"] + ((int)settings["radius"] != 1 ? " miles" : " mile");
}
@jasdev
jasdev / gist:3204954
Created July 30, 2012 05:16
Who uses Linked Lists anyways?
//Funny code segment I hacked together
private void TransportationPanel_Tap(object sender, System.Windows.Input.GestureEventArgs e)
{
settings["transportationMode"] = transportationOptions[(transportationOptions.IndexOf((string)settings["transportationMode"]) + 1) % 3];
switch ((string)settings["transportationMode"])
{
case "bike":
TransportationOption.Source = new BitmapImage(new Uri("Images/Icons/bike_icon_white.png", UriKind.Relative));
break;
case "car":
@simonmichael
simonmichael / gist:1185421
Created September 1, 2011 03:59
ghc-pkg-clean, ghc-pkg-reset
# unregister broken GHC packages. Run this a few times to resolve dependency rot in installed packages.
# ghc-pkg-clean -f cabal/dev/packages*.conf also works.
function ghc-pkg-clean() {
for p in `ghc-pkg check $* 2>&1 | grep problems | awk '{print $6}' | sed -e 's/:$//'`
do
echo unregistering $p; ghc-pkg $* unregister $p
done
}
# remove all installed GHC/cabal packages, leaving ~/.cabal binaries and docs in place.
@fj
fj / gist:1065069
Last active September 26, 2015 07:58
First Wednesdays Charlottesville info
@krisys
krisys / swype.py
Last active August 10, 2022 15:58
How swype works?
'''
The MIT License (MIT)
Copyright (c) 2013 Krishna Bharadwaj <krishna@krishnabharadwaj.info>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is