- you
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
>> rng(0) | |
>> A=randi(10, 2, 5); b=randi(100, 2, 1); | |
% A = b = | |
% 9 7 8 7 8 28 | |
% 10 8 4 2 1 5 | |
>> x1=A\b; x2=pinv(A)*b | |
% x1 = x2 = |
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
% Compare Ordinary Least square (no regularization), L2-reguarlized (Ridge), | |
% L1-regualarized (Lasso) regression in finding the sparse coefficient | |
% in a underdetermined linear system | |
rng(0); % for reproducibility | |
m = 50; % num samples | |
n = 200; % num variables, note that n > m | |
A = rand(m, n); | |
x = zeros(n, 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
enum label{A,B,C,D,E,N}; // N is exactly the size | |
char * desc="ABCDE" | |
vector<int> v(N); | |
// do sth. | |
cout << desc[A] << "'s value is " << v[A] << endl; |
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
/usr/local/include/boost/graph/random.hpp: In function ‘void boost::detail::randomize_property(G&, RandomGenerator&, Property, boost::edge_property_tag) [with Property = boost::edge_bundle_t, G = boost::adjacency_list<boost::setS, boost::vecS, boost::undirectedS, boost::no_property, EdgeProperty, boost::no_property, boost::listS>, RandomGenerator = boost::random::linear_congruential<int, 48271, 0, 2147483647, 399268537>]’: | |
/usr/local/include/boost/graph/random.hpp:255: instantiated from ‘void boost::randomize_property(G&, RandomGenerator&) [with Property = boost::edge_bundle_t, G = Graph, RandomGenerator = boost::minstd_rand]’ | |
random_graph.cpp:34: instantiated from here | |
/usr/local/include/boost/graph/random.hpp:247: error: no match for ‘operator=’ in ‘pm. boost::adj_list_edge_property_map<Directed, Value, Ref, Vertex, Property, Tag>::operator[] [with Directed = boost::undirected_tag, Value = EdgeProperty, Ref = EdgeProperty&, Vertex = long unsigned int, Property = boost::property<boost::edge_bundle_t, Edg |
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
#!/usr/bin/env python | |
# Author: Zigang Xiao <iveney # gmail.com> | |
# Date : 07/12/2011 | |
"""A python utility (wrapper for mutagen.m4a) to udpate tags for m4a file type. | |
Relies on m4a module in mutagen. | |
""" | |
from mutagen.m4a import M4A |
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
#!/usr/bin/env python | |
import string | |
import re | |
import sys | |
def get_gbk(value): | |
result = '' | |
for i in value: | |
result = result + chr(ord(i)) |
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
iveney@iveney-mbp:~$ # find the IP of dapenti.com | |
iveney@iveney-mbp:~$ dig dapenti.com | |
; <<>> DiG 9.7.3-P3 <<>> dapenti.com | |
;; global options: +cmd | |
;; Got answer: | |
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 30857 | |
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0 | |
;; QUESTION SECTION: |
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
<?php | |
$ip = $argv[1]; | |
$tags = get_meta_tags("http://www.geobytes.com/IpLocator.htm?GetLocation&template=php3.txt&IpAddress=$argv[1]"); | |
print "{$tags['city']}, {$tags['region']}, {$tags['country']}"; | |
?> |
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
% sparse signal recovery using L1 | |
rng(0); | |
N = 256; R = 3; C = 2; | |
% some superposition of sinoisoids, feel free to change and experiment | |
f = @(x) .5*sin(3*x).*cos(.1*x)+sin(1.3*x).*sin(x)-.7*sin(.5*x).*cos(2.3*x).*cos(x); | |
x = linspace(-10*pi, 10*pi, N); | |
y = f(x); |
OlderNewer