Skip to content

Instantly share code, notes, and snippets.

View prashnts's full-sized avatar
🥔
potatoes?

Prashant Sinha prashnts

🥔
potatoes?
View GitHub Profile
@prashnts
prashnts / PHP_Time_Ago.php
Last active August 29, 2015 14:06
A PHP Time Ago implementation, which cares about Timestamps WAY back in time, and returns their actual dates.
<?php
/**
* Returns a Pretty Time Ago string from given Timestamp. Returns bare date if
* timestamp is way back in past.
* @example "posted".timeAgo(xx): "posted just now".
* "posted a few minutes ago"
* "posted 14 minutes ago"
* "posted today at 7:00PM"
* "posted yesterday at 7:00PM"
* "posted 7:00PM, Friday 29 August 2014"
@prashnts
prashnts / JavaScript_Cookies.js
Created September 21, 2014 15:30
Javascript Cookies Access Implementation.
// Usage: Cookie.read(name),
// Cookie.create(name, value, days),
// Cookie.erase(name)
// Author: Prashant Sinha <firstname><lastname>@outlook.com, <firstname>@ducic.ac.in
var Cookie = {
create: function(name, value, days) {
var expires;
if (days) {
@prashnts
prashnts / indian.districts.geocoded.pincode.json
Created December 6, 2014 12:53
Indian District's GeoCoded Pin Code Data
{
"_description: Name of City, or Town": {
"State": "The Indian State under which this City/Town exists.",
"GeoCode": [
"Latitude",
"Longitude"
],
"PinCodes": [
"All",
"The",
$.scrollWindowTo = function(pos, duration, cb) {
if (duration == null) {
duration = 0;
}
if (pos === $(window).scrollTop()) {
$(window).trigger('scroll');
if (typeof cb === "function") {
cb();
}
return;
(function() {
var arrays, basicObjects, deepClone, deepExtend, deepExtendCouple, isBasicObject,
__slice = [].slice;
deepClone = function(obj) {
var func, isArr;
if (!_.isObject(obj || _.isFunction(obj))) {
return obj;
}
if (_.isDate(obj)) {
@prashnts
prashnts / ie8_node_enum.js
Created October 17, 2015 20:57
IE8 Node Enum
var Node = Node || {
ELEMENT_NODE: 1,
ATTRIBUTE_NODE: 2,
TEXT_NODE: 3
};
@prashnts
prashnts / lodash.custom.js
Created January 18, 2016 10:34
An extended custom build of lodash, generated with: # lodash exports=commonjs include=assign,clone,filter,each,map,random,reduce,some
/**
* @license
* Lo-Dash 2.4.1 (Custom Build) <http://lodash.com/>
* Build: `lodash exports="commonjs" include="assign,clone,filter,each,map,random,reduce,some"`
* Copyright 2012-2013 The Dojo Foundation <http://dojofoundation.org/>
* Based on Underscore.js 1.5.2 <http://underscorejs.org/LICENSE>
* Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
* Available under MIT license <http://lodash.com/license>
*/
;(function() {
@prashnts
prashnts / keybase.md
Created February 5, 2016 06:02
Keybase ID

Keybase proof

I hereby claim:

  • I am prashnts on github.
  • I am prashnts (https://keybase.io/prashnts) on keybase.
  • I have a public key whose fingerprint is 1FE8 3C8F 39BF 06FE 8C06 2E2B 2AD4 EFE5 6AB0 6289

To claim this, I am signing this object:

@prashnts
prashnts / app.js
Created October 14, 2016 15:06
Three.js Network animation used on CIC 404 pages, such as: https://ducic.ac.in/does-not-exists
function init() {
var e, t = 100,
n = 50,
r = 50,
i, s;
camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight,
1, 1e4);
camera.position.z = 100;
scene = new THREE.Scene;
renderer = new THREE.CanvasRenderer;
@prashnts
prashnts / pandas_ix.py
Created December 21, 2016 08:47
Perf comparison when using Integer vs. String indexes in a Pandas DF
import pandas as pd
import numpy as np
LIM = 100000
df_i = pd.DataFrame(np.random.randint(0, 100, size=(LIM, 4)), columns=list('ABCD'), index=list(range(0, LIM)))
df_s = pd.DataFrame(np.random.randint(0, 100, size=(LIM, 4)), columns=list('ABCD'), index=list(map(hex, range(0, LIM))))
## used in ipython
>>> %timeit -n 100 df.sort_values('A')