Skip to content

Instantly share code, notes, and snippets.

Aram Kocharyan aramk

Block or report user

Report or block aramk

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
aramk /
Created Nov 7, 2014
Support for object arguments in _.memoize()
# Adds support for using object arguments with _.memoize().
nextMemoizeObjKey = 1
memoizeObjectArg = (func) ->
_.memoize func, (obj) ->
key = obj._memoizeObjKey
unless key?
key = obj._memoizeObjKey = nextMemoizeObjKey++
# Example:
aramk /
Last active May 9, 2017
Publishing Jekyll to gh-pages branch
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $DIR
SELF=`basename $0`
View curl_header.php
define('COOKIE_FILE', 'cookie.txt');
define('HEADER_REGEX', '#^.*?(\r?\n){2}#msi');
$ch = curl_init();
curl_setopt_array($ch, array(
View DeferredQueueTest.js
// Add DeferredQueue and DeferredWrapper imports here
], function (Deferred, DeferredQueue, DeferredWrapper) {
var testDeferred = function () {
// Create a wrapper around a callback that returns a deferred object
return new DeferredWrapper(function () {
// Create a dummy deferred object to finish in 2 seconds
var df = new Deferred();
aramk / DeferredWrapper.js
Created Feb 9, 2013
Wraps a function in a dojo.Deferred object.
View DeferredWrapper.js
], function (declare, lang, Deferred) {
return declare([Deferred], {
// summary:
// Wraps a function in a dojo.Deferred object.
aramk / DeferredQueue.js
Created Feb 9, 2013
Resolves each dojo.Deferred in the queue sequentially, waiting for the previous to complete before moving on. Use this with DeferredWrapper:
View DeferredQueue.js
], function (declare, lang, Deferred, Log) {
// Internal ID for more useful logs
var queueID = 0;
aramk / float-on-top.js
Last active Dec 12, 2015
Floats an element on the top of the screen when we scroll the page beyond it. This is useful for page headers for instance. The "overlap" CSS class is added and you can style it how you like. Something with position: fixed, top:0, left: 0 works well.
View float-on-top.js
(function ($) {
function getPositionInfo(elem) {
var pos = {};
pos.docViewTop = $(window).scrollTop();
pos.docViewBottom = pos.docViewTop + $(window).height();
pos.elemTop = $(elem).offset().top;
pos.elemBottom = pos.elemTop + $(elem).height();
return pos;
aramk / ext-chart-theme-fix.js
Last active Dec 12, 2015
This is a redefinition of Ext.chart.theme to allow customisation of gradients for Ext JS.
View ext-chart-theme-fix.js
var NewThemeClass = function (config, base) {
// Arguments
config = Ext.apply({
gradientAngle: 45,
gradientDarkerRatio: 0.1
}, config);
var i = 0, l, colors, color,
seriesThemes, markerThemes,
aramk / field_widget.php
Last active Dec 10, 2015
A Wordpress widget base class which reduces the amount of code needed to create a simple widget with fields. Allows overriding a method adding more complex fields. This code should be placed in your theme's function.php file. You can then subclass Field_Widget whenever you like by following the example given.
View field_widget.php
* A Wordpress widget base class which reduces the amount of code needed to create a simple widget with fields. Allows overriding a method adding more complex fields.
class Field_Widget extends WP_Widget {
private $fields = array();
private $defaults = array();
private $names = array();
function update($new_instance, $old_instance) {
aramk / gist:4138482
Created Nov 24, 2012
Creates a link out a url string
View gist:4138482
String.prototype.linkify = function(target) {
target = typeof target != 'undefined' ? target : '';
return this.replace(/(http(s)?:\/\/(\S)+)/gmi, '<a href="$1" target="' + target + '">$1</a>');
"".linkify() // "<a href="" target=""></a>"
You can’t perform that action at this time.