Skip to content

Instantly share code, notes, and snippets.

@rainyear
rainyear / sqlite_truncate_cmd.sql
Last active October 19, 2017 15:13
TRUNCATE TABLE for sqlite.
delete from `TABLE`;
select * from sqlite_sequence;
update sqlite_sequence set seq=0 where name=`TABLE`;
@rainyear
rainyear / .XXXrc
Last active December 25, 2015 11:39
config *rc
.screenrc
----
startup_message off
hardstatus on
hardstatus alwayslastline
hardstatus string "%{.bW}%-w%{.rY}%n %t%{-}%+w %=%{..G} %H(%l) %{..Y} %Y/%m/%d %c:%s "
====
.inputrc
----
body {
font-family: Georgia,"Times New Roman",Times,"Kai","Kaiti SC","KaiTi","BiauKai","楷体","楷体_GB2312",serif;
font-size: 18px;
width: 50%;
line-height: 25px;
background: #bdc3c7;
color: #2c3e50;
}
hdiutil convert -format UDRW -o ~/path/to/target.img ~/path/to/ubuntu.iso
diskutil list
diskutil unmountDisk /dev/disk$N
sudo dd if=/path/to/downloaded.img of=/dev/rdiskN bs=1m
diskutil eject /dev/disk$N
@rainyear
rainyear / bubbles.m
Created December 14, 2013 12:12
Generate the diagnostic and antidiagnostic faces, the same process used in the experimental part that located the bubbles at '1' positions, at each SF band.
load allResults.mat
ySize = 256;
xSize = 256;
imSubSample=0;
nBands = 6; % number of bandpass (cannot be changed at the moment)
fGauss=mkGaussian(11);
fGauss1=fGauss(:,1);
@rainyear
rainyear / extract_data.m
Created December 14, 2013 12:16
Using the Ci_up as the threshold, the diagnostic proportions ( >= Ci_up ) were replaced with 1 and the nondiagnostic proportions( < Ci_up ) were replaced with 0, and then I got a binary diagnosticPlane, and the antidiagnostiPlane were obtained by replacing the diagnostic proportions with 0, and nondiagnostic proportions with 1.
DEBUG = 1;
namePat = 'gender_backup-%d.mat';
numSubjects = 16;
nLevels = 5;
Ci_up = [0.6914 0.6855 0.6728 0.6404 0.6228]; % upper confidence internal for 5 scale
allProportion = zeros(256,256,5,numSubjects);
@rainyear
rainyear / Mapwalk.py
Last active January 1, 2016 23:19
map a command(function) to all the files in current directory.
#!/usr/bin/env python
#-*- coding:utf-8 -*-
"""
Walking the destination directory(arg3) and using the command(arg2)
to process every file.
USAGE:
Mapwalk `function` /path/to/walk
"""
import sys
git rm -r --cached .
git add .
git commit -m "fixed untracked files"
@rainyear
rainyear / Android_Share_all.java
Last active August 29, 2015 14:01
Android Share to all codes
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_TEXT, getResources().getString(R.string.WAHT_YOU_WANT_TO_SAY));
shareIntent.setType("text/plain");
startActivity(Intent.createChooser(shareIntent, "WHAT_YOU_WANT_DISPLAY"));
AlertDialog.Builder info = new AlertDialog.Builder(this);
info.setTitle(getResources().getString(R.string.about_matters_txt).toString());
info.setMessage(getResources().getString(R.string.about_matters_txt_cont).toString());
info.setNegativeButton("隱藏", null);
AlertDialog showedInfo = info.show();
//DisplayMetrics metrics = getResources().getDisplayMetrics();
//showedInfo.getWindow().setGravity(Gravity.CENTER);
//showedInfo.getWindow().setLayout(LayoutParams.FILL_PARENT,
//(int) (metrics.heightPixels * 0.7));