This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var doAction = function() { | |
// do something when ctrl-enter is pressed | |
} | |
$(document).ready(function() { | |
var ctrlDown = false, | |
ctrlKey = 17, | |
cmdKey = 91, | |
enterKey = 13; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class LanguageUtils { | |
public static $COOKIE_LIFETIME = 10 * 365 * 24 * 3600; // 10 years | |
public static $LANGUAGE_KEY = "lang"; // key used as cookie name and to check $_POST and $_GET | |
/** | |
* Get the user language based on the following priorities: | |
* - "$LANGUAGE_KEY" parameter in $_POST data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.content.ContentProvider | |
import android.content.ContentValues | |
import android.database.Cursor | |
import android.net.Uri | |
import android.os.ParcelFileDescriptor | |
import java.io.File | |
import java.io.FileNotFoundException | |
/** | |
* Created by thorstenhack on 28.11.17. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
# Simple command script to download and add Google Material | |
# Design Icons ( https://material.io/icons/ ) to | |
# to your Android project. | |
import sys | |
import os | |
# Constants |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Responsive iFrames | |
- - - - - - - - - - - - - - - - - - - - */ | |
var $iframes = $('.iframe-responsive'); | |
if($iframes.length) { | |
var adaptIframes = function() { | |
$iframes.each(function(index, item) { | |
var $iframe = $(item); | |
var ratio = $iframes.attr('width') / $iframes.width(); | |
$iframe.css('height', $iframes.attr('height') / ratio); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// helper class to store tiny amounts of data that should persist across sessions | |
class GlobalStorage { | |
private static $instance; | |
public static function getInstance() { | |
if(!self::$instance) { | |
self::$instance = new GlobalStorage(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Method[] methods = this.getClass().getMethods(); | |
for (Method method : methods) { | |
MyAnnotation annotation = method.getAnnotation(MyAnnotation.class); | |
if (annotation != null) { | |
Object myAnnotationAttribute = annotation.value(); | |
// do whatever you want here | |
try { | |
method.invoke(this, methodParameters); | |
} catch (IllegalAccessException|InvocationTargetException e) { | |
e.printStackTrace(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
httpPost = function(url, params) { | |
var html = '<form action="' + url + '" method="post">'; | |
for(key in params) { | |
html += '<input type="text" name="'+ key +'" value="'+ params[key] +'" />'; | |
} | |
html += '</form>'; | |
$(html).submit(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mkdir tmp | |
echo 'Enter URL of old repo:' | |
read oldrepo | |
echo 'Enter URL of new repo:' | |
read newrepo | |
cd tmp | |
git clone --bare $oldrepo | |
REPO=`ls` | |
cd $REPO | |
git remote add destination $newrepo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ViewHolder { | |
@SuppressWarnings("unchecked") | |
public static <T extends View> T get(View view, int id) { | |
SparseArray<View> viewHolder = (SparseArray<View>) view.getTag(); | |
if (viewHolder == null) { | |
viewHolder = new SparseArray<View>(); | |
view.setTag(viewHolder); | |
} | |
View childView = viewHolder.get(id); | |
if (childView == null) { |
NewerOlder