Skip to content

Instantly share code, notes, and snippets.

@kurorido
kurorido / gist:5846b20920625916cc95
Created August 17, 2015 13:45
Regular Expression Cheat Sheet
# [0-9].json
\d+[.][j][s][o][n]
# the end of every line.
(?>\x0D\x0A?|[\x0A-\x0C\x85\x{2028}\x{2029}])
# begin of lines.
^[a-zA-z0-9!@#$")(*&!+_-]
@kurorido
kurorido / gist:52e3e0cd95aaeb2a52d9
Created August 18, 2015 15:08
Sublime shortcuts cheat sheet
# 跳到特定的檔案
Ctrl + P
可輸入 <檔案名稱>:<行號> 來快速跳躍
# 跳到特定行
Ctrl + G
# 轉換 Emmet
Ctrl + E
@kurorido
kurorido / capistrano-laravel-deploy.rb
Created October 5, 2015 07:43 — forked from arhea/capistrano-laravel-deploy.rb
Capistrano 3 deploy script for Laravel 4.
# config valid only for Capistrano 3.1
lock '3.1.0'
set :application, "" # EDIT your app name
set :scm, :git
set :repo_url, "" # EDIT your git repository
set :keep_releases, 3
var getClosestValues = function(a, x) {
var lo = -1, hi = a.length;
while (hi - lo > 1) {
var mid = Math.round((lo + hi)/2);
if (a[mid] <= x) {
lo = mid;
} else {
hi = mid;
}
}
https://www.digitalocean.com/community/questions/how-to-change-swap-size-on-ubuntu-14-04
Just follow these steps:
Make all swap off
sudo swapoff -a
Resize the swapfile
sudo dd if=/dev/zero of=/swapfile bs=1M count=1024
@kurorido
kurorido / gulpfile.js
Created April 15, 2016 03:28 — forked from ktmud/gulpfile.js
An example gulpfile.js with bower components and live reload support
var BatchStream = require('batch-stream2')
var gulp = require('gulp')
var coffee = require('gulp-coffee')
var uglify = require('gulp-uglify')
var cssmin = require('gulp-minify-css')
var bower = require('gulp-bower-files')
var stylus = require('gulp-stylus')
var livereload = require('gulp-livereload')
var include = require('gulp-include')
var concat = require('gulp-concat')
@kurorido
kurorido / button_drawable_selector.xml
Created April 16, 2016 07:43
Android button different state background
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_pressed="false"
android:drawable="@drawable/title_button_back">
</item>
<item
android:state_pressed="true"
android:drawable="@drawable/title_button_back_h">
</item>
<?php
set_error_handler(function($errno, $errstr, $errfile, $errline, array $errcontext) {
// error was suppressed with the @-operator
if (0 === error_reporting()) {
return false;
}
throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<div id="log"></div>
<script>
@kurorido
kurorido / index.html
Created May 10, 2016 17:57
Toggle HTML5 video tag fullsceen with enter key
<video id="Video1" width="1134" height="906" controls>
<source src="test_1.mp4" type="video/mp4">
Your browser does not support the video tag.
</video>
<script>
document.addEventListener("keypress", function(e) {
e = e || window.event;
if(e.keyCode == 13) {