Skip to content

Instantly share code, notes, and snippets.

View mamod's full-sized avatar

Mamod Mehyar mamod

View GitHub Profile
@mamod
mamod / git-recover-branch.md
Created April 23, 2019 11:10 — forked from jbgo/git-recover-branch.md
How to recover a git branch you accidentally deleted

UPDATE: A better way! (August 2015)

As pointed out by @johntyree in the comments, using git reflog is easier and more reliable. Thanks for the suggestion!

 $ git reflog
1ed7510 HEAD@{1}: checkout: moving from develop to 1ed7510
3970d09 HEAD@{2}: checkout: moving from b-fix-build to develop
1ed7510 HEAD@{3}: commit: got everything working the way I want
70b3696 HEAD@{4}: commit: upgrade rails, do some refactoring
@mamod
mamod / console.js
Created May 20, 2017 01:16
Minimal console log for Duktape
(function (global) {
var origPrint = print;
var _serialize = function (obj) {
var str = JSON.stringify(obj, function(key, value) {
if (key && typeof value == 'object' && obj === value) {
return '#[[Circular]]#';
}
else if (typeof value === 'function') {
return '#[[Function]]#';
}
@mamod
mamod / c
Created October 29, 2014 19:10
duktape compile
static const int process_eval(duk_context *ctx) {
const char *buf = duk_get_string(ctx, 0);
const char *filename = duk_get_string(ctx, 1);
duk_push_string(ctx, filename);
if (duk_pcompile_string_filename(ctx, 0, buf)){
printf("%s\n", duk_safe_to_string(ctx, -1));
printf("%s\n", duk_safe_to_string(ctx, -2));
duk_destroy_heap(ctx);
exit(1);
}
$(function(){
$('.viewModal').modal({
target : '#modal',
animation : 'top',
position : 'center'
});
});
@mamod
mamod / modal html
Last active December 23, 2015 05:49
<!-- triggering element -->
<button class="viewModal">Click Me</button>
<!-- modal element -->
<div id="modal" style="display:none;width:50%;...">
Your Modal Content with your own styles
</div>
<!-- include modal plugin right after loading jQuery -->
<script src="jQuery.js" type="text/javascript"></script>
<!-- add easing jquery plugin if you want to use easing option -->
<script src="jquery.easing.1.3.js" type="text/javascript"></script>
<script src="modal.js" type="text/javascript"></script>
//trigger modal view
$('.someElement').click(function(){
$('#modal').modal('view',{
easing : 'linear',
position : 'bottom',
animation : 'top left',
speed : 1000
});
});
//set global options
$(document).modal({
easing : 'easeInOutBounce',
speed : 600,
animation : 'top',
position 'center',
overlayClose : true,
on : 'click'
});
$(element).swipeLeft(function(e){
console.log('swiped left');
});
//or
$(element).on('swipeRight',function(e){
console.log(e.pageX);
});
<!-- include jQuery.Touch plugin right after loading jQuery -->
<script src="js/jQuery.js" type="text/javascript"></script>
<script src="js/jQuery.Touch.js" type="text/javascript"></script>