Skip to content

Instantly share code, notes, and snippets.

//https://jsbin.com/kekilasuwu/edit?html,css,js,console,output
Vue.directive('orderby',{
twoWay: true,
isLiteral: true,
checked: false,
bind: function(el,binding, vNode){
var self = this;
const onclick = event => {
event.stopPropagation()
vNode.context.$emit(binding.expression, event);
@aloha1003
aloha1003 / v-jquery-change.js
Created July 21, 2017 09:57 — forked from Galadirith/v-jquery-change.js
custom vue js directive for jquery events
Vue.directive('jquery-change', {
twoWay: true,
bind: function() {
var self = this;
$(self.el).on('change', function() {
self.set(this.value);
});
},
update: function(data) {
if(data) {
#!/bin/bash
echo "Get Instance: "
fileName="iplist.txt"
privateIPFileName="privateIp.txt"
iplist=$(aws ec2 describe-instances --filters Name=tag:Name,Values=whoscome | jq -r '.Reservations | .[].Instances[0].NetworkInterfaces[0].Association.PublicIp' > $fileName)
privateIp=$(aws ec2 describe-instances --filters Name=tag:Name,Values=whoscome | jq -r '.Reservations | .[].Instances[0].NetworkInterfaces[0].PrivateIpAddress' > $privateIPFileName)
i=1
osascript <<EOF
tell application "iTerm2"
@aloha1003
aloha1003 / webpack.nginx.conf
Created May 25, 2017 02:18 — forked from SiZapPaaiGwat/webpack.nginx.conf
webpack-dev-server configuration in nginx on development server
upstream ws_server {
server 127.0.0.1:8080;
}
server {
listen 80;
server_name 10.1.2.225;
location / {
proxy_pass http://ws_server/;
@aloha1003
aloha1003 / Open iterm tab here
Created May 18, 2017 01:55 — forked from eric-hu/Open iterm tab here
Apple script to open an iterm2 tab from right-clicking on a file or folder in Finder. To use: (1) Open Automator (2) Create a new service (3) Change "Service receives selected" drop downs to "Files or folders" in "Finder" (4) Select "Run applescript" from the sidebar, then paste this script in and save
-- Adapted from these sources:
-- http://peterdowns.com/posts/open-iterm-finder-service.html
-- https://gist.github.com/cowboy/905546
--
-- Modified to work with files as well, cd-ing to their container folder
on run {input, parameters}
tell application "Finder"
set my_file to first item of input
set filetype to (kind of (info for my_file))
-- Treats OS X applications as files. To treat them as folders, integrate this SO answer:
functions:
hello:
handler: handler.hello
events:
- http:
path: hello
method: get
response:
contentType: application/json;charset=UTF-8
template:
@aloha1003
aloha1003 / webpack.config.js
Created April 23, 2017 04:10
Webpack with auto scan path for multiple entry points and recursive path mapping
'use strict';
var webpack = require('webpack');
var ExtractTextPlugin = require("extract-text-webpack-plugin");
// Map common libraries with aliases
var providePlugins = new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery',
@aloha1003
aloha1003 / custom
Last active February 26, 2017 06:45
動態調整validation 規則
<?php
class Model extends BaseModel {
public $defaultRuleAry = []; //預設規則
public function validation() { //驗證輸入
//根據 $this->defaultRuleAry 來驗證
return true;
}
public function save(array $options = array())
<?php
//Enter your code here, enjoy!
function arrayListPointer(...$index): Closure{
$item = array_shift($index);
$composeIndex = count($index) > 0 ? arrayListPointer(...$index) : function($x) {
return $x;
};
return function($x) use ($item, $composeIndex) {
return '['.$item.']'.$composeIndex($x);
};
try {
//do something
} catch (\Exception $ex){
//Write to Log
echo $ex->getMessage();
}