Skip to content

Instantly share code, notes, and snippets.

@shrekuu
shrekuu / form.html
Created May 11, 2017 10:27 — forked from siamak/form.html
Image Validator (Dimension) with javascript.
<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-1.9.1.js"></script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<h3>Image Validator: </h3>
@shrekuu
shrekuu / gradient.js
Last active May 11, 2017 10:21 — forked from siamak/gradient.js
Steps in Gradient
/**
* GradientArray • Steps gradient.
* @author Siamak Mokhtari <hi@siamak.work>
* @date 06/21/16.
*/
class GradientArray {
// Convert a hex color to an RGB array e.g. [r,g,b]
// Accepts the following formats: FFF, FFFFFF, #FFF, #FFFFFF
hexToRgb(hex) {
let r, g, b, parts;
@shrekuu
shrekuu / back-button-event-handler.ts
Last active March 13, 2018 13:40
ionic 2 double press back button to exit app
// Note: I ended up using a service to quickly regiser and unregister the event when users navigate through pages.
// Please read before using.
import { Injectable } from '@angular/core';
import { Events, Platform } from "ionic-angular";
import { ToastControllerProvider } from "../toast-controller/toast-controller";
@Injectable()
export class BackButtonEventHandlerProvider {
# Thanks to this post:
# http://blog.ikato.com/post/15675823000/how-to-install-consolas-font-on-mac-os-x
$ brew install cabextract
$ cd ~/Downloads
$ mkdir consolas
$ cd consolas
$ curl -O http://download.microsoft.com/download/f/5/a/f5a3df76-d856-4a61-a6bd-722f52a5be26/PowerPointViewer.exe
$ cabextract PowerPointViewer.exe
$ cabextract ppviewer.cab
@shrekuu
shrekuu / .zshrc-for-mac-with-php5.6.sh
Last active June 15, 2017 02:51
.zshrc for macOS Sierra with system php5.6 and system apache2
# Path to your oh-my-zsh installation.
export ZSH=~/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="robbyrussell"
# Uncomment the following line to use case-sensitive completion.
@shrekuu
shrekuu / packager.js
Last active November 1, 2017 04:19
ancient js namespace
// Note: these code is tooooo old.
// version 1
function(t) {
function e(t) {
for (var e, i = ("" + t).split("."), r = window, o = 0; e = i[o]; o++) n.call(r, e) || (r[e] = {}), r = r[e];
return r
}
var n = Object.prototype.hasOwnProperty;
t.packager = function(t, n) {
@shrekuu
shrekuu / FilterIfAjax.php
Last active September 4, 2018 07:13
laravel pjax middleware; A pjax middleware for Laravel 5; dump error if server gives error
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Symfony\Component\DomCrawler\Crawler;
class FilterIfPjax
@shrekuu
shrekuu / httpd-vhosts.conf
Created April 6, 2016 11:30
sample; mac, apache, reverse proxy
# @温柔的码农
<VirtualHost *:80>
ServerName example.com # change to your domain
ProxyRequests off
ProxyPreserveHost On
<Proxy *>
Order deny,allow
Allow from all
@shrekuu
shrekuu / ip_in_range.php
Created December 10, 2015 04:56 — forked from tott/ip_in_range.php
php check if IP is in given network range
/**
* Check if a given ip is in a network
* @param string $ip IP to check in IPV4 format eg. 127.0.0.1
* @param string $range IP/CIDR netmask eg. 127.0.0.0/24, also 127.0.0.1 is accepted and /32 assumed
* @return boolean true if the ip is in this range / false if not.
*/
function ip_in_range( $ip, $range ) {
if ( strpos( $range, '/' ) == false ) {
$range .= '/32';
}
@shrekuu
shrekuu / install-go-lang-2.sh
Last active April 6, 2016 11:43
mac install go lang
#!/usr/bin/env sh
# As of 20130519, go 1.1 has been released.
# The proccess of the gist should be OK for go 1.1 .
# magic pause
function pause(){
read -p "$*"
}