Skip to content

Instantly share code, notes, and snippets.

View safareli's full-sized avatar

Irakli Safareli safareli

View GitHub Profile
<!DOCTYPE NETSCAPE-Bookmark-file-1>
<!-- This is an automatically generated file.
It will be read and overwritten.
DO NOT EDIT! -->
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
<TITLE>Bookmarks</TITLE>
<H1>Bookmarks</H1>
<DL><p>
<DT><H3 ADD_DATE="1393402804" LAST_MODIFIED="1393404076" PERSONAL_TOOLBAR_FOLDER="true">Bookmarks bar</H3>
<DL><p>
@safareli
safareli / times.js
Last active August 29, 2015 13:59
javascript times function I made when working on testing random numbers, but can be used anywhere.
var timesGen = function(t,useArguments){
return function(callback,thisArg){
thisArg = thisArg || null;
return function(){
for(var i = 0;i < t; i++){
callback.apply(thisArg,(useArguments) ? arguments : [i]);
}
}
}
};
String.prototype._toIntArray = function(func){
func = (typeof func == 'undefined') ? function(a){return a;}: func;
for (var b = [], i=0; i<this.length;i++)
b.push(func(this.charCodeAt(i)));
return b;
};
Array.prototype._intToString = function(func){
func = (typeof func == 'undefined') ? function(a){return a;}: func;
for (var b = '', i=0; i<this.length;i++)
b += String.fromCharCode(func(this[i]));
@safareli
safareli / on.js
Last active August 29, 2015 14:00
on.js
function beforeAfterify(array, prefix, that, args){
if(array[prefix]){
array[prefix].apply(that[prefix],args);
}
}
function listen(element,prefix, before, after, that, event, callback){
var listener = function(){
beforeAfterify(before, prefix, that, arguments);
callback.apply(that[prefix],arguments);
var each = function(callback){
return function(array){
for(var i = 0;i < array.length; i++){
var arg = [].slice.call(arguments);
arg[0] = array[i];
callback.apply(this,arg);
}
};
};
@safareli
safareli / storer.js
Last active August 29, 2015 14:02
in memory data store
function storer(key, val) {
if (arguments.length === 1)
return this[key];
else if (arguments.length === 0)
return this;
if (typeof val === "function")
return function () {
return val.apply(storer.bind(this, key), arguments);
}.bind(this);
setTimeout(console.log.bind(console, this), 1);
function arrayToFuncs() {
var functions = arguments;
return function (args) {
return [].map.call(functions, function (func, i) {
if (func == null)return args[i];
return func.call(undefined, args[i]);
});
}
}
@safareli
safareli / memoize.js
Last active August 29, 2015 14:05
memorize recursive function results
/*
// implementation 1
function memoize(func){
var store = {};
return function recursive(a){
if(store[a] == null) {
store[a] = func(recursive,a);
}
return store[a];
};
@safareli
safareli / profile_page.php
Created August 11, 2014 12:39
make possable to use <profile> inside block's pages field
<?php
/**
* Implements hook_module_implements_alter().
*/
function MODULE_NAME_module_implements_alter(&$implementations, $hook) {
if ($hook == 'block_list_alter') {
// We need our module to run hook_block_list_alter() first.
$module = 'MODULE_NAME';
// Pull out our own hook implementation details.
$group = array($module => $implementations[$module]);
@safareli
safareli / Drupal Web Services
Last active August 29, 2015 14:06
სასარგებლო ლინკები RESTfull ვებ სერვისებზე Drupal-ის ჭრილში
Drupal Web Services