Skip to content

Instantly share code, notes, and snippets.

@qlife
qlife / urlquote.py
Created June 18, 2011 08:26
Demonstrating how to use python to quote / unquote url
#!/usr/local/bin/python
# -*- coding: UTF-8 -*-
import urllib
def main():
ss = 'http://www.google.com.tw/?q=亞伯拉罕'
quoted_str = urllib.quote_plus(ss)
print quoted_str
print urllib.unquote_plus(quoted_str)
@qlife
qlife / php_filter.php
Created July 26, 2011 07:17
PHP filter extension
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>PHP filter</title>
<style type="text/css">
form {
margin: 0;
padding: 0px;
@qlife
qlife / vecofvec.cpp
Created January 21, 2012 14:59
vector<int> of vector<int>
#include<iostream>
#include<vector>
#define ROWMAX 12
int main()
{
std::vector< std::vector<int> > array2d;
for ( int rowI = 0 ; rowI < ROWMAX; ++rowI )
{
@qlife
qlife / gist:2960552
Created June 20, 2012 15:39
Yesterday
$ history yesterday
Time limit exceed
$ uname -r
A-Liar-SPEAK-unrealistic-dream-2.7.6-no-arch
$ explain
Are you a liar?
Are you a liar?
Are you a liar?
kernel panic
@qlife
qlife / add.cpp
Created February 13, 2013 08:59 — forked from anonymous/add.cpp
#include "add.hpp"
long add(long x, long y)
{
return x + y;
}
@qlife
qlife / call_npp.bat
Created March 9, 2014 11:55
Launch notepad++
@SET NPP_EXE="C:\Program Files (x86)\Notepad++\notepad++.exe"
@if "%1"=="" goto noparam
@call %NPP_EXE% %1
@goto safe_exit
REM Prompt no parameter and than leave.
:noparam
@echo "call_npp.bat: please at least give the file name."
@goto safe_exit
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
// compare the "UVAOJ example" and the standard BufferedReader approach. The "getchar()" like apporach better until the input
// data grows to 1GB size scale. This is because the "getchar()" may spent too much CPU time to create new String() object.
public class Main {
private static final BufferedReader stdin;
@qlife
qlife / gist:879f7a9437e59fe37ad6
Last active August 4, 2022 15:27
scanf() with 'm' modifier to allocate memory for C string
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#include <time.h>
int main()
{
int a = 11111 * 11111;
@qlife
qlife / disable_touch_panel.sh
Created November 9, 2016 03:05
disable_touch_panel.sh
#!/bin/sh
XINPUT=`which xinput`
PAD_ID=`${XINPUT} | grep "Touchpad" | awk -F"\t" '{print $2}' | awk -F"=" '{print $2}'`
${XINPUT} set-prop $PAD_ID "Device Enabled" 0
@qlife
qlife / gist:30350c91a3f5d5c5f76c1308429af7b5
Created February 1, 2017 14:02
STEP_FOR_AUTO_INSTALL_LAPTOP
#my steps to record:
sudo apt-get update && sudo apt-get upgrade -y
sudo apt-get remove ibus
sudo apt-get install fcitx fcitx-table-boshiamy
im-config
sudo apt-get install screen
wget https://raw.githubusercontent.com/qlife/dot.files/master/dot.screenrc -O .screenrc
mkdir -p ~/bin