This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Install git | |
cd $HOME | |
sudo yum -y update | |
sudo yum -y install git | |
# Prepare the public key, which will be used later | |
cp ~/.ssh/authorized_keys /tmp/Default.pub | |
chmod a+r /tmp/Default.pub | |
# Use the user git to install gitolite from source. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import re | |
# Initial request for blackboard | |
r = requests.get('http://blackboard.andrew.cmu.edu/') | |
# Authenticaton | |
payload = { 'j_username' : '<your username>', 'j_password' : '<your password>', 'j_continue' : '1', 'submit' : 'Login' } | |
r2 = requests.post(r.url, data=payload, cookies=r.cookies) | |
# Manually proceed with the form | |
url = 'https://blackboard.andrew.cmu.edu/Shibboleth.sso/SAML2/POST' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Basically just Follow the install instructions in https://github.com/gitlabhq/gitlabhq/blob/stable/doc/installation.md. | |
If you encounter problems, check this: | |
1. If the system complains about pid files in the very last step, change 'restart' to 'start'. | |
If it doesn't work, use 'sudo ./resque.sh' in Step 6. | |
2. I encountered 502 Bad Gateway error. Solution is in https://groups.google.com/forum/?fromgroups#!topic/gitlabhq/u9AMESyd-N0 | |
Restart the server after the modification. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% Inuitive example for LSH with toy data | |
dimension = 30; | |
sampleNum = 1000; | |
hashBitCount = 16; | |
x = rand(sampleNum, dimension); % data points to hash | |
w = rand(dimension, hashBitCount); % w vector in hash function | |
w = w ./ repmat(sqrt(diag(w' * w)'), dimension, 1); % normalization | |
projection = x * w; % Do the projection | |
t = median(projection); % empirically provides good result | |
hashCode = sign(x * w - repmat(t, sampleNum, 1)); % replace x with test data in test phase |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function demo | |
% This is a toy example of implementig a hash table in matlab | |
hashBits = 20; | |
function h = hash(s) | |
% A toy hash function for vectors/strings | |
% Note this function accepts a matrix as input thus is fast in matlab | |
h = mod(sum(s, 2), 2^hashBits) + 1; % Note this produces a 16-bit hash code. | |
% Plus one to prevent outputting 0 as hash code, which will cause | |
% problems in the following code. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var semaphor = new Semaphore(50, 50); // We allow at most 50 threads for crawling | |
var resultPins = new List<Pin>(); // Results stored here | |
foreach (var pin in new HashSet<string>(pinIdList)) | |
{ | |
semaphor.WaitOne(); | |
Console.Write(">"); | |
var pinClient = new WebClient(); | |
pinClient.DownloadStringCompleted += (sender, ex) => | |
{ | |
var html = ex.Result.Replace("\n", ""); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Not sure why this example doesn't work, but the framework is like this. | |
# Welcome to point out the bug. Thanks in advance! | |
import re | |
content = '<html><p class="name">John</p><p class="profile">http://facebook.com/john</p></html>' | |
# More info about re in http://docs.python.org/library/re.html | |
name_result = re.match('class="name">(\w+)<', content).group(1) | |
profile_result = re.match('class="profile">(.+)<', content).group(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" regular settings | |
syntax on | |
set si ai nu et | |
set shiftwidth=4 | |
set tabstop=4 | |
set bs=2 | |
colorscheme wombat | |
set autochdir autoread autowrite | |
set incsearch ignorecase smartcase |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <amp.h> | |
#include <iostream> | |
#include <ctime> | |
#include <cstdlib> | |
#define TS 16 | |
using namespace std; | |
using namespace concurrency; | |
int main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
num=$(curl -s xkcd.com | grep -oh -m 1 'v" href="/[0-9]*' | sed 's/v" href="\/'//) | |
n=$[ $RANDOM % $num ] | |
curl -s xkcd.com/$n/ | grep '<img.*comics' | mail -a 'Content-Type: text/html' -s 'xkcd daily pick' <email> |
OlderNewer