Skip to content

Instantly share code, notes, and snippets.

@toioski
toioski / script.applescript
Last active June 5, 2023 01:30
Automatically Open Safari Dev Tools for iOS Simulator
-- `menu_click`, by Jacob Rus, September 2006.
-- Ref: https://stackoverflow.com/questions/14669542/automatically-open-the-safari-debugger-when-the-iphone-simulator-is-launched
on menu_click(mList)
local appName, topMenu, r
-- Validate our input
if mList's length < 3 then error "Menu list is not long enough"
-- Set these variables for clarity and brevity later on
@yulanggong
yulanggong / vimsheet.md
Last active June 7, 2017 07:50
Vim Cheat Sheet

Vim Cheat Sheet

Global

  • :help keyword - open help for keyword
  • :o file - open file
  • :saveas file - save file as
  • :close - close current pane

Cursor movement

/**
* Copyright (c) 2016-2018 Richard Connamacher. Permission is granted to use this code under
* the terms of the Simplified BSD License, https://opensource.org/licenses/BSD-2-Clause
*
* This monkey-patches the native ECMAScript 6 Promise class to add support for
* the Promise Rejection Events unhandledrejection and rejectionhandled, as defined
* in ECMAScript 7 and the HTML Living Standard.
*
* THIS FILE MUST NOT BE TRANSPILED into ECMAScript 5. Builtins like Promise can only
* be subclassed using native ES6 classes, not backwards-compatible ES5 constructor
@yulanggong
yulanggong / github-page-switcher.js
Last active September 19, 2016 01:59
🔃 Switch between github.io and github.com
//Bookmarklet:
//javascript:!function(){var o=location.host.slice(-9);"github.io"==o?location.href.replace(/\/\/([^\.]+)\.github\.io\/([^\/]+)/,function(o,t,i){location.href="https://github.com/"+t+"/"+i}):"ithub.com"==o&&location.href.replace(/github\.com\/([^\/]+)\/([^\/]+)/,function(o,t,i){location.href="https://"+t.toLowerCase()+".github.io/"+i})}();
(function(){
var host = location.host.slice(-9);
if(host == 'github.io'){
location.href.replace(/\/\/([^\.]+)\.github\.io\/([^\/]+)/, function(a, name, project){
location.href = 'https://github.com/' + name + '/' + project;
})
} else if (host == 'ithub.com') {
@yulanggong
yulanggong / micro-jquery.js
Last active April 18, 2016 08:46
micro jQuery
var $ = function(s){
if(!(this instanceof $)){
return new $(s);
}
this.push.apply(this, document.querySelectorAll(s));
}
$.fn = $.prototype = [];
$.fn.each = function(fn){

好街坊外卖单

盖饭类

小炒肉盖饭          15元
香干回锅肉盖饭        15元
鱼香烘蛋盖饭         13元
鱼香肉丝盖饭         15元
宫爆鸡丁盖饭         15元
@chrisjlee
chrisjlee / querySelector.polyfill.js
Created February 12, 2014 17:39
IE document.querySelector() polyfill
if (!document.querySelectorAll) {
document.querySelectorAll = function (selectors) {
var style = document.createElement('style'), elements = [], element;
document.documentElement.firstChild.appendChild(style);
document._qsa = [];
style.styleSheet.cssText = selectors + '{x-qsa:expression(document._qsa && document._qsa.push(this))}';
window.scrollBy(0, 0);
style.parentNode.removeChild(style);
@Daniel-Hug
Daniel-Hug / arr-stat.js
Last active December 11, 2023 14:46
JavaScript statistical functions for arrays: max, min, range, midrange, sum, mean / average, median, modes, variance, standard deviation, mean absolute deviation, z scores
var arr = {
max: function(array) {
return Math.max.apply(null, array);
},
min: function(array) {
return Math.min.apply(null, array);
},
range: function(array) {
@un33k
un33k / nginx.conf
Last active January 17, 2023 22:36
Enable Nginx to send Content-Dispositions on specific files
server {
listen *:80;
server_name www.example.com;
rewrite ^(.*) http://example.com $1 permanent;
}
server {
listen *:80;
server_name example.com;
@nightire
nightire / How to use Backbone.js.md
Last active November 14, 2017 08:15
How to use Backbone.js

Simple Starting Point

创建 Model

var Person = Backbone.Model.extend();