Skip to content

Instantly share code, notes, and snippets.

View rageandqq's full-sized avatar

Sameer Chitley rageandqq

View GitHub Profile
@rubo77
rubo77 / create-gist.sh
Last active August 30, 2020 09:41 — forked from s-leroux/pgist.sh
A utility to create a gists from command line - for support, please check the repo https://github.com/ceremcem/create-gist
#!/bin/bash
GITHUB_USERNAME=rubo77
if [ "$1" == "" ]; then
echo 'usage: gistfile-post.sh filename [gistname]'
exit 0
fi
# 0. file name for the Gist
@stefanbuck
stefanbuck / upload-github-release-asset.sh
Last active November 26, 2023 12:40
Script to upload a release asset using the GitHub API v3.
#!/usr/bin/env bash
#
# Author: Stefan Buck
# License: MIT
# https://gist.github.com/stefanbuck/ce788fee19ab6eb0b4447a85fc99f447
#
#
# This script accepts the following parameters:
#
# * owner
@bearfrieze
bearfrieze / comprehensions.md
Last active December 23, 2023 22:49
Comprehensions in Python the Jedi way

Comprehensions in Python the Jedi way

by Bjørn Friese

Beautiful is better than ugly. Explicit is better than implicit.

-- The Zen of Python

I frequently deal with collections of things in the programs I write. Collections of droids, jedis, planets, lightsabers, starfighters, etc. When programming in Python, these collections of things are usually represented as lists, sets and dictionaries. Oftentimes, what I want to do with collections is to transform them in various ways. Comprehensions is a powerful syntax for doing just that. I use them extensively, and it's one of the things that keep me coming back to Python. Let me show you a few examples of the incredible usefulness of comprehensions.

@mdsrosa
mdsrosa / dijkstra.py
Created November 21, 2015 04:36
Modified Python implementation of Dijkstra's Algorithm (https://gist.github.com/econchick/4666413)
from collections import defaultdict, deque
class Graph(object):
def __init__(self):
self.nodes = set()
self.edges = defaultdict(list)
self.distances = {}
def add_node(self, value):
@rageandqq
rageandqq / css-property-check.js
Created March 25, 2015 14:16
Check if a browser supports a specific CSS property
//Taken from SpinKit (https://github.com/tobiasahlin/SpinKit)
function browserSupportsCSSProperty(propertyName) {
var elm = document.createElement('div');
propertyName = propertyName.toLowerCase();
if (elm.style[propertyName] != undefined)
return true;
var propertyNameCapital = propertyName.charAt(0).toUpperCase() + propertyName.substr(1),
domPrefixes = 'Webkit Moz ms O'.split(' ');
@rageandqq
rageandqq / angular-percent-filter.js
Created March 25, 2015 05:21
AngularJS Percentage Filter
//take in decimal b/w 0 and 1, display as face value (b/w 0 and 100%) with a specified # decimal places
angular.module('myModule', []).filter('percentage', ['$filter', function($filter) {
return function(input, decimalPlaces) {
return $filter('number')(100 * input, decimals) + '%';
};
}]);
@pkerpedjiev
pkerpedjiev / SelectableForceDirectedGraph
Last active May 25, 2023 04:59
D3 Selectable Force-Directed Graph
.
@paul91
paul91 / nyct-gtfs.js
Created September 17, 2014 15:00
Nodejs NYCT GTFS decoding example
// All thanks goes to: http://stackoverflow.com/a/25733922
var ProtoBuf = require("protobufjs");
var http = require('http');
// MTA Realtime endpoint http://datamine.mta.info/mta_esi.php?key=xxxx
var feedUrl = "...";
// Initialize from .proto file
// Requires nyct-subway.proto and gtfs-realtime.proto
@kerimdzhanov
kerimdzhanov / random.js
Last active April 20, 2024 03:21
JavaScript: get a random number from a specific range
/**
* Get a random floating point number between `min` and `max`.
*
* @param {number} min - min number
* @param {number} max - max number
* @return {number} a random floating point number
*/
function getRandomFloat(min, max) {
return Math.random() * (max - min) + min;
}
@kachayev
kachayev / dijkstra.py
Last active April 14, 2024 06:58
Dijkstra shortest path algorithm based on python heapq heap implementation
from collections import defaultdict
from heapq import *
def dijkstra(edges, f, t):
g = defaultdict(list)
for l,r,c in edges:
g[l].append((c,r))
q, seen, mins = [(0,f,())], set(), {f: 0}
while q: