Skip to content

Instantly share code, notes, and snippets.

View hasinhayder's full-sized avatar
🚀
Back on track, yayyyy!

Hasin Hayder hasinhayder

🚀
Back on track, yayyyy!
View GitHub Profile
@hasinhayder
hasinhayder / enq-css.php
Last active February 21, 2021 07:08
generate wp_enqueue_style calls for all the css files in current directory
#!/usr/bin/env php
<?php
foreach(glob("*.css") as $css){
echo "wp_enqueue_style( 'wptheme-{$css}', get_template_directory_uri().'/css/{$css}',null,'1.0');\n";
}
@hasinhayder
hasinhayder / enq-js.php
Last active March 4, 2016 15:59
generate wp_enqueue_script calls for all the js files in the current directory
#!/usr/bin/env php
<?php
foreach(glob("*.js") as $js){
echo "wp_enqueue_script( 'wptheme-{$js}', get_template_directory_uri().'/js/{$js}', array('jquery'),'1.0',true);\n";
}
def main():
print max([2,3,4,5,1,2,11,2,8,3,10])
def max(nums):
_max=nums[0]
for n in nums:
_max = _max if (_max>n) else n
return _max
if __name__ == "__main__": main()
@hasinhayder
hasinhayder / gist:b2f61dc219557eb9e06d
Last active August 29, 2015 14:15
counter problem :)
var counter = function(arg){
var local;
function incr(arg2){
arg2 = arg2 == undefined ? 1 : arg2;
return !local ? (local = arg2, incr) : (local += arg2, local);
}
return incr(arg);
}
var cnt = counter(5);
@hasinhayder
hasinhayder / gist:60c4fa9ca16a31ab8763
Created February 18, 2015 19:39
counter problem v 2
var counter = function(arg){
arg = arg == undefined ? 1 : arg;
var me = arguments.callee;
return me.count ? ( me.count += arg, me.count ) : ( me.count = arg, me );
}
var cnt = counter(5);
cnt();
cnt();
console.log(cnt(5)); //shud return 12
@hasinhayder
hasinhayder / im.js
Created February 23, 2015 22:52
Immutability via __defineGetter__
var me = {
_first:"Count",
_last: "Dracula";
}
me.__defineGetter__('first', function() { return this._first; });
me.__defineGetter__('last', function() { return this._last; });
me.first= "Die!";
console.log(me.first); //still shows "Count"
@hasinhayder
hasinhayder / laravel query listener
Last active May 20, 2020 19:16
display all the queries being executed in laravel
<?php
/* add a listener to display all the queries being executed in laravel */
DB::listen( function ( $query ) {
var_dump( $query->sql );
} );
@hasinhayder
hasinhayder / _ide_helper.php
Created July 11, 2016 20:01 — forked from barryvdh/_ide_helper.php
Laravel IDE Helper for Netbeans / PhpStorm / Sublime Text 2 CodeIntel, generated using https://github.com/barryvdh/laravel-ide-helper
<?php
/**
* A helper file for Laravel 5, to provide autocomplete information to your IDE
* Generated for Laravel 5.1.31 (LTS) on 2016-03-01.
*
* @author Barry vd. Heuvel <barryvdh@gmail.com>
* @see https://github.com/barryvdh/laravel-ide-helper
*/
namespace {
@hasinhayder
hasinhayder / Sublime Text 3 Keybindings
Created July 16, 2016 17:13
Sublime Text 3 Keybindings
[
{ "keys": ["super+shift+f"], "command": "reindent" , "args": {"single_line": false}},
{ "keys": ["super+d"], "command": "duplicate_line" },
{ "keys": ["super+v"], "command": "paste_and_indent" },
{ "keys": ["super+shift+v"], "command": "paste" },
{ "keys": ["ctrl+n"], "command": "advanced_new_file" },
{ "keys": ["super+l"], "command": "show_overlay", "args": {"overlay": "goto", "text": ":"} },
]
@hasinhayder
hasinhayder / curl_progress.php
Created September 1, 2016 20:16 — forked from bdunogier/curl_progress.php
PHP/cURL download progress monitoring
<?php
file_put_contents( 'progress.txt', '' );
$targetFile = fopen( 'testfile.iso', 'w' );
$ch = curl_init( 'http://ftp.free.org/mirrors/releases.ubuntu-fr.org/11.04/ubuntu-11.04-desktop-i386-fr.iso' );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt( $ch, CURLOPT_NOPROGRESS, false );
curl_setopt( $ch, CURLOPT_PROGRESSFUNCTION, 'progressCallback' );
curl_setopt( $ch, CURLOPT_FILE, $targetFile );