Skip to content

Instantly share code, notes, and snippets.

@perchouli
perchouli / file_permissions.sh
Created December 29, 2018 21:00
File permissions for Laravel
# If Nginx+Laravel displays a blank page
# cd to Laravel root folder
sudo chown -R www-data:www-data .
sudo usermod -aG www-data $USER
sudo find . -type f -iwholename '*.git*' -exec chmod 664 {} \;
sudo find . -type d -iwholename '*.git*' -exec chmod 775 {} \;
sudo chgrp -R www-data storage bootstrap/cache
sudo chmod -R 775 storage bootstrap/cache
@perchouli
perchouli / bash
Created August 27, 2018 12:41
Fix Adobe Illustrator Java Error
# Run csrutil disable on Recovery
sudo mkdir /System/Library/Java/JavaVirtualMachines/1.6.0.jdk
sudo ln -s '/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents' /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents
sudo mkdir /System/Library/Java/Support/Deploy.bundle
@perchouli
perchouli / gist:a2b4c315bb4eaa43e575b96c0a97f5c2
Created October 1, 2016 15:34
frameworkpython.py(matplotlib+virtualenv/0
#!/bin/bash
# frameworkpython -m IPython --matplotlib
# what real Python executable to use
PYVER=2.7
PATHTOPYTHON=/usr/local/bin/
PYTHON=${PATHTOPYTHON}python${PYVER}
# find the root of the virtualenv, it should be the parent of the dir this script is in
@perchouli
perchouli / gist:44407b632c996dbf4a81
Last active September 22, 2015 07:27
Trigger touch event (Firefox)
function tiggerTouchEvent(target, type, identifier, x, y) {
//Firefox
var e = document.createEvent('TouchEvent'),
touch = document.createTouch(window, target, identifier),
touches,
targetTouches,
changedTouches;
if (type == 'touchend') {
touches = document.createTouchList();
@perchouli
perchouli / gist:1ce51553cc788ecbabe1
Created August 20, 2014 12:36
Chinese Provinces and Cities 中国省市数据
{"11":{"en":"Beijing","cn":"\u5317\u4eac\u5e02","citys":{"1101":{"cn":"\u5e02\u8f96\u533a\uff08\u5317\u4eac\uff09","en":"City(Beijing)"},"1102":{"cn":"\u53bf\uff08\u5317\u4eac\uff09","en":"County(Beijing)"}}},"12":{"en":"Tianjin","cn":"\u5929\u6d25\u5e02","citys":{"1201":{"en":"City(Tianjing)","cn":"\u5e02\u8f96\u533a(\u5929\u6d25)"},"1202":{"en":"County(Tianjing)","cn":"\u53bf(\u5929\u6d25)"}}},"13":{"en":"Hebei","cn":"\u6cb3\u5317\u7701","citys":{"1301":{"en":"Shijiazhuang","cn":"\u77f3\u5bb6\u5e84\u5e02"},"1302":{"en":"Tangshan","cn":"\u5510\u5c71\u5e02"},"1303":{"en":"Qinhuangdao","cn":"\u79e6\u7687\u5c9b\u5e02"},"1304":{"en":"Handan","cn":"\u90af\u90f8\u5e02"},"1305":{"en":"Xingtai","cn":"\u90a2\u53f0\u5e02"},"1306":{"en":"Baoding","cn":"\u4fdd\u5b9a\u5e02"},"1307":{"en":"Zhangjiakou","cn":"\u5f20\u5bb6\u53e3\u5e02"},"1308":{"en":"Chengde","cn":"\u627f\u5fb7\u5e02"},"1309":{"en":"Cangzhou ","cn":"\u6ca7\u5dde\u5e02"},"1310":{"en":"Langfang","cn":"\u5eca\u574a\u5e02"}}},"14":{"en":"Shanxi","cn":"\u5c71\u8
@perchouli
perchouli / gist:5618937
Created May 21, 2013 10:47
调用XMPP给Gtalk发消息
#!/usr/bin/env python
# coding: utf-8
from pyxmpp.jid import JID
from pyxmpp.message import Message
from pyxmpp.jabber.client import JabberClient
from pyxmpp.jabber.simple import send_message
from pyxmpp import streamtls
import time
@perchouli
perchouli / gist:5150114
Created March 13, 2013 08:00
JAVA生成多说Remote Auth
import net.sf.json.JSONObject;
import java.util.HashMap;
import java.util.Map;
import java.security.InvalidKeyException;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.Mac;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
@perchouli
perchouli / gist:5062386
Last active December 14, 2015 09:08
Java 调用 ICTCLAS分词(自定义词库)
package ICTCLAS.I3S.test;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import ICTCLAS.I3S.AC.ICTCLAS50;
public class Test_ImportUsrDict {
@perchouli
perchouli / gist:4358842
Created December 22, 2012 13:06
调用又拍云模块实现上传
# -*- coding: utf-8 -*-
import os
from .upyun import UpYun
class qqFileUploader(object):
def __init__(self, work):
self.work = work
self.allowedExtensions = [".jpg",".png",".jpeg",]
self.sizeLimit = 1024000
@perchouli
perchouli / gist:4123427
Created November 21, 2012 06:45
Cassandra批量操作
#!/usr/bin/php
<?php
require 'bootstrap.php';
require_once LIBRARY_PATH.'/thrift/packages/cassandra/Cassandra.php';
require_once LIBRARY_PATH.'/thrift/packages/cassandra/cassandra.Cassandra.client.php';
require_once LIBRARY_PATH.'/thrift/packages/cassandra/cassandra_types.php';
use cassandra\Compression;
$config = require 'configs/cassandra.php';
$pool = new phpcassa\Connection\ConnectionPool($config['keyspace'], $config['servers']);