Skip to content

Instantly share code, notes, and snippets.

View jasdev's full-sized avatar

Jasdev Singh jasdev

View GitHub Profile
@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":
@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:3210317
Created July 30, 2012 21:14
C# at it's finest
foreach (DAO daoFile in daoFiles)
{
StoredProcedure correspondingPoc = (from x in sProcs
where x.file == daoFile.calledProc select x).FirstOrDefault();
if (correspondingPoc != null)
{
IEnumerable<Error> except = correspondingPoc.possibleErrors.Except(daoFile.errorsCaught, new ErrorComparer());
}
}
@jasdev
jasdev / gist:3214252
Created July 31, 2012 06:31
Time representation fun
TimeSpan t = TimeSpan.FromSeconds(time);
f.dataString = distance + " mi" + "\n" + string.Format((t.Hours == 0 ? "" : "{0:D1}h:") + (t.Minutes > 9 ? "{1:D2}m" : "{1:D1}m"), t.Hours, t.Minutes);
@jasdev
jasdev / gist:3233676
Created August 2, 2012 04:47
Pardon the brevity
for(int i = 0; i < badges.length(); i++){
badgeList.add(new Badge(((JSONObject) (badges.get(i))).getString("name"), ((JSONObject) (badges.get(i))).getString("description"), ((JSONObject) (badges.get(i))).getString("id")));
}
@jasdev
jasdev / Runner.java
Created October 31, 2012 03:55
Blum Micali PRG
public class Runner {
/**
* @param args
*/
public static void main(String[] args) {
//Generate the first 100 bits from Blum-Micali PRG with p = 34319, g = 4, and seed x = 1022
long p = 34319;
long g = 4;
@jasdev
jasdev / Runner2.java
Created October 31, 2012 15:49
Create duplicates through recursion
//Helping out a friend with a quick hack to make duplicates recursively (made in 2 mins)
import java.util.LinkedList;
public class Runner2 {
/**
* @param args
*/
@jasdev
jasdev / DummyContent.java
Created November 2, 2012 04:58
Async Task with Content
package com.cs4720.drinkengine_android.dummy;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@jasdev
jasdev / paste.txt
Created November 20, 2012 21:11
Keep fighting.
"Sometimes when I find myself comparing myself to others and losing
steam mentally/emotionally, I have to remind myself where I started, the
attitude I had when I began, and how I have already achieved things I never
thought possible and that there is no reason for that to change so long as I
stay committed, balanced, consistent and hungry."
@jasdev
jasdev / jsonp.js
Created December 3, 2012 21:51
JSONP Call Scaffolding
function postCall(data) {
console.log("Data from JSON");
}
$(document).ready(function () {
var endpoint = //URL here
$.ajax({url: endpoint, dataType: "jsonp", success: postCall});
});