Skip to content

Instantly share code, notes, and snippets.

View samarpanda's full-sized avatar
👋

Samar Panda samarpanda

👋
View GitHub Profile
@jtallant
jtallant / ob_flush-examples.php
Created August 4, 2012 22:40
ob_flush() php examples
<?php
/*
== ob_end_flush() ==
Flush (send) the output buffer and turn off output buffering
== ob_end_clean() ==
Clean (erase) the output buffer and turn off output buffering
== ob_get_contents() ==
@amoilanen
amoilanen / webcrawler.js
Last active March 24, 2022 03:14
Simple PhantomJS-based web crawler library
//PhantomJS http://phantomjs.org/ based web crawler Anton Ivanov anton.al.ivanov@gmail.com 2012
//UPDATE: This gist has been made into a Node.js module and now can be installed with "npm install js-crawler"
//the Node.js version does not use Phantom.JS, but the API available to the client is similar to the present gist
(function(host) {
function Crawler() {
this.visitedURLs = {};
};
@brettz9
brettz9 / html5-dataset.js
Last active April 29, 2023 14:58
Dataset Shim
/**
* Add dataset support to elements
* No globals, no overriding prototype with non-standard methods,
* handles CamelCase properly, attempts to use standard
* Object.defineProperty() (and Function bind()) methods,
* falls back to native implementation when existing
* Inspired by http://code.eligrey.com/html5/dataset/
* (via https://github.com/adalgiso/html5-dataset/blob/master/html5-dataset.js )
* Depends on Function.bind and Object.defineProperty/Object.getOwnPropertyDescriptor (polyfills below)
* All code below is Licensed under the X11/MIT License
@samarpanda
samarpanda / SimpleStructure.js
Last active October 12, 2015 23:48
Module reveal pattern.
(function(undefined){
"use strict"
if(jQuery === undefined)
return;
var $ = window.jQuery;
var sBASE = function(){
var self,
/**
* Cache all dom nodes to below config object. To prevent unecessary multiple dom traverse using jQuery(As i am using jQuery here.).
*/
@samarpanda
samarpanda / Sublime Text 2 keyboard shortcut.md
Last active January 26, 2023 16:02
My favorite keyboard shortcuts Sublime Text 2

Keyboard shortcuts for Sublime Text 2

  1. Multi-selection: To enable multi-selection, you have several options
  • Press Alt or Command and then click in each region where you require a cursor.
  • Select a block of line, and then press Shit + Command + L
  • Place the cursor over a particular word, and press Control/Command + D repeatedly to select additional occurences of that word.
  • Alternatively, add an additional cursor at all occurences of a word by typing Alt+F3 on Windows, or Ctrl+Command+G on the Mac.
  1. Find all occurence of a word in a file and edit all of those at a time: > Command + F then Option + Enter. All the occurance of the word should be editable.
(function() {
// NOTE: I have intentionally avoided the use of jQuery in
// the next two functions so as not to obscure any details.
// Updates the DOM in such a way that layout is constantly
// computed and thrown away.
var UpdateThrash = function(data) {
// Get all the labels
var spans = document.querySelectorAll('.item .lab');
@kvnsmth
kvnsmth / example-subtree-usage.md
Last active March 5, 2023 21:58
A real world usage for git subtrees.

Let's say you have an iOS project, and you want to use some external library, like AFNetworking. How do you integrate it?

With submodules

Add the project to your repo:

git submodule add git@github.com:AFNetworking/AFNetworking.git Vendor/AFNetworking

or something to that effect.

@cobyism
cobyism / gh-pages-deploy.md
Last active June 5, 2024 21:48
Deploy to `gh-pages` from a `dist` folder on the master branch. Useful for use with [yeoman](http://yeoman.io).

Deploying a subfolder to GitHub Pages

Sometimes you want to have a subdirectory on the master branch be the root directory of a repository’s gh-pages branch. This is useful for things like sites developed with Yeoman, or if you have a Jekyll site contained in the master branch alongside the rest of your code.

For the sake of this example, let’s pretend the subfolder containing your site is named dist.

Step 1

Remove the dist directory from the project’s .gitignore file (it’s ignored by default by Yeoman).

@samarpanda
samarpanda / Man_Pages_Usage.md
Last active December 12, 2015 08:49
Skim through man mages more efficiently!

Using man pages

Use man pager

By default man usages less as its pages. Less can be used

  1. D or Control D - Advance half a page.
  2. U or Control U - Go back half a page.
  3. Space or F or Control F - Advance a page.
  4. B or Control B - Go back a page.
@domenic
domenic / interop.md
Last active July 7, 2022 19:47
`module.exports =` and ES6 Module Interop in Node.js

module.exports = and ES6 Module Interop in Node.js

The question: how can we use ES6 modules in Node.js, where modules-as-functions is very common? That is, given a future in which V8 supports ES6 modules:

  • How can authors of function-modules convert to ES6 export syntax, without breaking consumers that do require("function-module")()?
  • How can consumers of function-modules use ES6 import syntax, while not demanding that the module author rewrites his code to ES6 export?

@wycats showed me a solution. It involves hooking into the loader API to do some rewriting, and using a distinguished name for the single export.

This is me eating crow for lots of false statements I've made all over Twitter today. Here it goes.