Skip to content

Instantly share code, notes, and snippets.

@qlife
qlife / test_is_digits.py
Last active February 11, 2018 06:48
Python: Test if a string literal is a numeric literal
#!/usr/bin/env python
import timeit
def my_tester(x):
try:
int(x)
except:
return False
else:
@qlife
qlife / PEP7.md
Last active April 21, 2017 13:27
PEP7 C Style Guide with GNU indent

PEP7 C Indent

Something might works.

I got this configuration from some stackoverflow links or mailing list archives but I cannot recall the exactly source link. Please correct me if you know the credits should go to whom.

indent -npro -kr -i4 -ts8 -sob -l79 -ss -ncs -cp1 -bad -nce -psl -nut x.c
@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
@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: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;
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 / 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
@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 / 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 / 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 )
{