Skip to content

Instantly share code, notes, and snippets.

@VSeryoga
VSeryoga / array_sort.php
Created April 12, 2017 08:55
Сортировка многомерного массива по 2 знчениям
<?
function sort_nested_arrays( $array, $args = array('votes' => 'desc') ){
usort( $array, function( $a, $b ) use ( $args ){
$res = 0;
$a = (object) $a;
$b = (object) $b;
foreach( $args as $k => $v ){
if( $a->$k == $b->$k ) continue;
@junpluse
junpluse / SwipeNavigationController.h
Last active April 26, 2024 08:15
Simple implementation for swipe-to-back/forward UINavigationController
#import <UIKit/UIKit.h>
@interface SwipeNavigationController : UINavigationController <UIGestureRecognizerDelegate>
@property (nonatomic, readonly) NSArray *poppedViewControllers;
- (void)clearPoppedViewControllers;
@property (nonatomic, readonly) UISwipeGestureRecognizer *leftSwipeGestureRecognizer;
@abbotto
abbotto / jss.js
Last active April 26, 2024 08:15
JavaScript StyleSheets
/**
* JSS
* Author: Jared Abbott
* Copyright 2015 Jared Abbott
* Distributed under the MIT license
*
* @param {Object}
*/
var _jss = function(jss, combinator) {
var _toString = Function.prototype.call.bind(Object.prototype.toString);
@abbotto
abbotto / xhrBinary.js
Last active April 26, 2024 08:13
Get binary data with XHR in most browsers including IE8+
/*!
* xhrBinary.js
* Author: Jared Abbott
* Copyright 2015 Jared Abbott
* Distributed under the MIT license
*/
var xhrBinary = function(url, fn) {
// RESOURCES
// http://mgran.blogspot.com/2006/08/downloading-binary-streams-with.html
@abbotto
abbotto / nano-template.js
Last active April 26, 2024 08:13
A templating solution implemented in JavaScript [207 bytes minified+gzipped]
// Author: Jared Abbott
// Created: December 2015
// License: MIT
var template = function(tpl, data) {
// Make sure the cache is available
var w = window;
w.tplCache = !w.tplCache ? {} : w.tplCache;
// Prepare and load the template
tpl = ('"' + tpl.replace(/\{\{(.*?)\}\}/g, '"+$1+"') + '"').split(/\'+ | + \'/);
@thirdj
thirdj / templating.js
Created December 9, 2013 08:56
// Simple JavaScript Templating // John Resig - http://ejohn.org/ - MIT Licensed
(function(){
var cache = {};
this.tmpl = function tmpl(str, data){
// Figure out if we're getting a template, or if we need to
// load the template - and be sure to cache the result.
var fn = !/\W/.test(str) ?
cache[str] = cache[str] ||
tmpl(document.getElementById(str).innerHTML) :
@loadenmb
loadenmb / snippet-pwsh_xorhexbyte.ps1
Created October 19, 2019 18:41
powershell XOR encoder / decoder and hex / byte - byte / hex conversions
# powershell XOR encoder / decoder and hex / byte - byte / hex conversions
# usage: execute & see output
# xor encoder / decoder
function xor($bytes, $string) {
$newBytes = @();
for ($i = 0; $i -lt $bytes.Count; $i++) {
$newBytes += $bytes[$i] -bxor $string[$i % $string.Length];
}
return $newBytes;
(function() {
var cache = {};
this.tmpl = function tmpl(str, data) {
// Figure out if we're getting a template, or if we need to
// load the template - and be sure to cache the result.
var fn = !/\W/.test(str) ?
cache[str] = cache[str] ||
tmpl(document.getElementById(str).innerHTML) :
@moresheth
moresheth / microtemplating.js
Created October 12, 2011 16:31
John Resig's MicroTemplating with Curly Braces
/*
This comes directly from John Resig's MicroTemplating, but with {%= %} instead of <%= %> for the dynamic sections.
http://ejohn.org/blog/javascript-micro-templating/
This lets you use just natural Javascript, along with whatever JS library you're using, and can be inside of a Rails erb template, or whatever.
Used with a template inside the HTML of the page:
<script type="text/html" id="user_tmpl">
@tanyuan
tanyuan / smart-caps-lock.md
Last active April 26, 2024 08:11
Smart Caps Lock: Remap Caps Lock to Control AND Escape

Smart Caps Lock: Remap to Control AND Escape (Linux, Mac, Windows)

Caps Lock 變成智慧的 Control 以及 Escape

  • 單獨輕按一下就是 Escape
  • 若按下時同時按著其他鍵,就會是 Control

這應該是 Vim 和 Emacs 的最佳解了!(Emacs? Bash 的快捷鍵就是 Emacs 系列的)

  • Send Escape if you tap Caps Lock alone.