Skip to content

Instantly share code, notes, and snippets.

View lotabout's full-sized avatar

Jinzhou Zhang lotabout

View GitHub Profile
@LiuJi-Jim
LiuJi-Jim / hrtime.js
Last active October 27, 2015 09:39
HRT(High Resolution Timing) in JavaScript
var hrtime = (function(){
if (typeof window !== 'undefined'){
// browser
if (typeof window.performance !== 'undefined' && typeof performance.now !== 'undefined'){
// support hrt
return function(){
return performance.now();
};
}else{
// oh no..
@cyrilis
cyrilis / colors.sh
Created November 24, 2014 07:03
A ImageMagick Script Can Generate Color Palettes JSON Format. Usage: ./colors.sh IMAGE-PATH COLOR-NUMBERS eg: ./colors.sh /Users/Cyril/Downloads/photo2.jpg 10
dir="." #Set the default temp dir
tmpA1="$dir/spectrumhist_1_$$.png"
tmpB1="$dir/spectrumhist_1_$$.cache"
trap "rm -f $tmpA1 $tmpB1; exit 0" 0 #remove temp files
trap "rm -f $tmpA1 $tmpB1; exit 1" 1 2 3 15 #remove temp files
if [ $# -eq 2 ]
then
colors=$2
else
colors=8
@zhenyi2697
zhenyi2697 / urllib2_upload.py
Created March 27, 2013 08:57
Python: urllib2 upload file demo
#!/usr/bin/python
# demo from here: http://pymotw.com/2/urllib2/index.html#uploading-files
import itertools
import mimetools
import mimetypes
from cStringIO import StringIO
import urllib
import urllib2
@kmassada
kmassada / README.md
Last active September 4, 2021 12:22
Vagrant and KVM(QEMU) on Centos7

Libvirt

yum group install -y "Development Tools"
yum -y install qemu-kvm libvirt virt-install bridge-utils libvirt-devel  libxslt-devel libxml2-devel libvirt-devel libguestfs-tools-c
echo "net.ipv4.ip_forward = 1"|sudo tee /etc/sysctl.d/99-ipforward.conf
sysctl -p /etc/sysctl.d/99-ipforward.conf
@acgotaku
acgotaku / baidupan
Last active April 26, 2023 04:00
新版百度云盘aria2c导出下载 ,目前只实现了核心功能.
// ==UserScript==
// @name 百度网盘aria2导出工具
// @author acgotaku311
// @description 一个方便吧百度网盘的Aria2rpc导出的脚本。
// @encoding utf-8
// @include http://*n.baidu.com/s/*
// @include http://*n.baidu.com/disk/home*
// @include http://*n.baidu.com/share/link*
// @include https://*n.baidu.com/s/*
// @include https://*n.baidu.com/disk/home*
@rsim
rsim / gist:d11652a8336137832df9
Created April 7, 2015 08:01
How to get the current Unix timestamp in SQL

Get the current Unix timestamp (seconds from 1970-01-01T00:00:00Z) in SQL.

  • MySQL: UNIX_TIMESTAMP()
  • PostgreSQL: CAST(EXTRACT(epoch FROM NOW()) AS INT)
  • MS SQL: DATEDIFF(s, '1970-01-01', GETUTCDATE())
  • Oracle: (CAST(SYS_EXTRACT_UTC(SYSTIMESTAMP) AS DATE) - DATE'1970-01-01') * 86400
@kennwhite
kennwhite / Install_Alpine_Linux_3.3_on_VirtualBox_OSX.md
Last active June 21, 2023 15:05
Howto: Install Alpine Linux 3.3 on VirtualBox OSX

Howto: Install Alpine Linux 3.3 on VirtualBox OSX

  • Latest Standard ISO version x86_64 is recommended (http://alpinelinux.org/downloads/)
  • Create new VM ("Linux 2.6 / 3.x / 4.x (64-bit)")
  • 1 CPU w/ 512BM RAM and 1 GB default (VDI) disk is more than sufficient
  • Default networking (NAT)
  • Boot and add Alpine ISO as attached virtual install media
  • Default root password is blank (though note - ssh PermitRootLogin defaults to disallow blank passwords and: prohibit-password; switch to yes for Host ssh)
  • Run setup-alpine
  • Defaults are fine, but you do want "sys" disk setup to sda, y to confirm
@gornostal
gornostal / Unicode.md
Created November 22, 2015 10:15
Python 2.7. Unicode Errors Simply Explained

Python 2.7. Unicode Errors Simply Explained

I know I'm late with this article for about 5 years or so, but people are still using Python 2.x, so this subject is relevant I think.

Some facts first:

  • Unicode is an international encoding standard for use with different languages and scripts
  • In python-2.x, there are two types that deal with text.
    1. str is an 8-bit string.
  1. unicode is for strings of unicode code points.
@darcyliu
darcyliu / install_spark_centos7.sh
Created April 1, 2016 09:40
Install Spark on CentOS 7
#!/bin/bash
# Install Spark on CentOS 7
yum install java -y
java -version
yum install wget -y
wget http://downloads.typesafe.com/scala/2.11.7/scala-2.11.7.tgz
tar xvf scala-2.11.7.tgz
sudo mv scala-2.11.7 /usr/lib
sudo ln -s /usr/lib/scala-2.11.7 /usr/lib/scala
@magnetikonline
magnetikonline / README.md
Last active March 14, 2024 22:48
IE 7/8/9/10/11 Virtual machines from Microsoft - Linux w/VirtualBox installation notes.