Another alternative to checkinstall

Checkinstall didn’t work for me in CentOS 7 even after following this guide: http://www.patrickmin.com/linux/tip.php?name=checkinstall_fedora_13 and using –fstrans = no. Solution: https://github.com/jordansissel/fpm Using nginx 1.7.3 as an example:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
$ ./configure --sbin-path=/usr/local/sbin/nginx --with-http\_ssl\_module --prefix=/usr/local/nginx
$ make install DESTDIR = /tmp/nginxinstalldir && cd /tmp/nginxinstalldir
$ fpm -s dir -t rpm -n nginx -v 1.7.3 -d 'openssl-devel' -d 'openssl-libs' -d 'openssl' -d 'pcre' -d 'pcre-devel' -d 'zlib' -d 'zlib-devel' usr/
# rpm -qpR nginx-1.7.3-1.x86_64.rpm
openssl-devel
openssl-libs
openssl
pcre
pcre-devel
zlib
zlib-devel
rpmlib(PayloadFilesHavePrefix) <= 4.0-1
rpmlib(CompressedFileNames) <= 3.0.4-1
# rpm -ivh nginx-1.7.3-1.x86_64.rpm

Of course, this is by no means a substitute to properly packaging packages for upstream using rpm-build, but it is perfect for compiling from source quickly without having files strewn all over the place, especially when there is no make uninstall.

GNU Screen on Steroids

Note: This is an old post, from an old blog far, far away Append this to your ~/.bashrc:

1
2
3
case "$TERM" in
screen*) PROMPT_COMMAND='echo -ne "�33k�33�134"'
esac

and this to your .screenrc:

1
2
hardstatus alwayslastline '%{= G}\[ %{G}%H %{g}\]\[%= %{= w}%?%-Lw%?%{= R}%n*%f %t%?%{= R}(%u)%?%{= w}%+Lw%?%= %{= g}\]\[ %{y}Load: %l %{g}\]\[%{B}%Y-%m-%d %{W}%c:%s %{g}\]'
shelltitle '$ |bash'

Courtesy of http://superuser.com/questions/244299/gnu-screen-how-to-update-dynamically-the-title-of-a-window and http://beerpla.net/2009/10/06/supercharge-your-gnu-screen-with-a-power-taskbar-and-never-feel-lost-again/

If you want to keep your splits/panes persistent even when you detach: The short is answer is that you can’t. The longer answer is that you can fake it. (Note: the next screen release, probably numbered 4.1.0, will be able to remember display layouts.) Splits are a property of your display. The process managing your screen session doesn’t really know about them; only the single process that’s displaying the session does. Thus, the screen session can’t remember the splits because it doesn’t know about them, and once you detach, the process that did know about them has exited. The hack is to use nested screen sessions. Start one session and give it some escape sequence that you won’t use much (or just disable its escape character completely). Bind your usual detach key sequence to this screen session. Now, start or attach to your main screen session. All of your work will be done in the inner session, and you can split your display. When you detach, however, it will be the outer session that detaches, so your splits in the inner session will be preserved.

http://aperiodic.net/screen/faq#when_i_split_the_display_and_then_detach_screen_forgets_the_split

Compiling UnrealIRCD on an iPod Touch 2G

Note: This is an old post, from an old blog far, far away

Prerequisites

wget "http://www.unrealircd.com/downloads/Unreal3.2.10.1.tar.gz" | tar -xvzf -

Configuring

For some reason I had to run the ./configure as root after cd’ing into the directory where I extracted the files as the mobile user; perhaps due to an inability to run unsigned applications?

checking whether we are cross compiling… configure: error: in /var/mobile/Unreal3.2.10.1': configure: error: cannot run C compiled programs. If you meant to cross compile, use–host’.

After running as root, everything went rather smoothly. Edit dpath and spath as you wish.

1
./configure --with-showlistmodes --enable-ssl --enable-ziplinks --enable-inet6 --with-listen=5 --with-dpath=/var/mobile/UnrealIRCD-build --with-spath=/var/mobile/UnrealIRCD-build/src/ircd --with-nick-history=2000 --with-sendq=3000000 --with-bufferpool=18 --with-permissions=0600 --with-fd-setsize=1024 --enable-dynamic-linking

I forgot to use ‘time’ but estimate it perhaps took around 20 minutes. After make && make install:

1
2
3
openssl genrsa -out server.key 2048
openssl req -new -x509 -key server.key -out server.cert.pem -days 1826
cp server.key server.key.pem

to generate the certificate and key needed for the SSL connection. After running ./unreal start ; it required some source modules in the build folder and the config file for the IRCD.

1
2
cp -r /var/mobile/Unreal3.2.10.1/src/ ../UnrealIRCD-build/
cp /var/mobile/UnrealIRCD-build/src/example.conf /var/mobile/UnrealIRCD-build/unrealircd.conf

Edit the config file as you wish!…

How I understand RSA

wpid-wp-1402514522645-1024x735.jpeg Euler’s totient function is defined as the number of positive integers relatively prime to n (including 1). E.g. φ(12) = 4 ( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12), and φ(15) = 8. http://www.thescienceforum.com/mathematics/14111-modular-multiplicative-inverse-context-rsa.html https://en.wikibooks.org/wiki/Algorithm_Implementation/Mathematics/Extended_Euclidean_algorithm https://docs.google.com/viewer?url=www.math.utah.edu/~fguevara/ACCESS2013/Euclid.pdf as to why the extended Euclid’s algo can be used to find the modular multiplicative inverse wpid-wp-1402514649564-1024x767.jpeg wpid-wp-1402514730357-1024x491.jpeg https://docs.google.com/viewer?url=ftp://ftp.rsasecurity.com/pub/pkcs/pkcs-1/pkcs-1v2-1.pdf https://docs.google.com/viewer?url=ftp://ftp.rsasecurity.com/pub/rsalabs/rsa_algorithm/rsa-oaep_spec.pdf In particular, ^ page 9. OAEP is the padding scheme ( http://crypto.stackexchange.com/questions/10145/rsa-pcks1-v2-1-rsaes-oaep-algorithm http://crypto.stackexchange.com/questions/2074/rsa-oaep-input-parameters ) , whereas I2OSP and OS2IP (on page 4); what really helped things come full circle for me is realizing how they represent arbitrary data as an integer (first converting it to an octet string). Without further do, let’s test our generated keys by encrypting and decrypting the number 521 (any number smaller than 527, our modulus, will do. ( http://stackoverflow.com/questions/10061626/message-length-restriction-in-rsa ) )

1
2
3
4
5
6
7
8
$ python
Python 2.7.5+ (default, Feb 27 2014, 19:37:08)
[GCC 4.8.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> print 521**41 % 527
346
>>> print 346**281 % 527
521

Note that if we try with a larger number…

1
2
3
4
>>> print 1000**41 % 527
411
>>> print 411**281 % 527
473

Nope. What really helped things come full circle once again (or full sphere..) http://en.wikipedia.org/wiki/Pretty_Good_Privacy#Confidentiality http://superuser.com/questions/383732/how-does-ssh-encryption-work It makes more sense to use a symmetric encryption algorithm with high throughput to encrypt the data first, then use PKI to encrypt and transfer the key. And that is how the world works.

Good First Bug

https://wiki.mozilla.org/Good_first_bug So!… I realize the change isn’t as trivial in FF 29+ since the switch to the nasty curved tabs. Regardless, here’s my solution: http://forums.mozillazine.org/viewtopic.php?f=38&t=2799203 and add the code to remove sidebars and this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
.tabbrowser-tab {
-moz-binding: url("chrome://browser/content/tabbrowser.xml#tabbrowser-tab");
}
.tabbrowser-tab[selected="true"] {
font-weight: bold !important;
color: rgba(255,255,255,1) !important;
background-image: linear-gradient(rgba(102,51,102,.85), rgba(102,51,102,.85) 50%),
linear-gradient(-moz-dialog, -moz-dialog) !important;
}
tab:not([selected="true"]) {
background-color: #2F0 !important;
color: gray !important;
}

into browser.css ](/wp-content/uploads/2014/05/green_tabs-150x91.jpg)

The Strong Induction Axiom

These are notes taken from the Lec 3 | MIT 6.042J Mathematics for Computer Science, Fall 2010 video lecture, which can be found at https://www.youtube.com/watch?v=NuGDkmwEObM#t=4658

What exactly does the Strong in Strong Induction mean? Let $P(n)$ be any predicate. if $P(0)$ is true then $\forall n (P(0) \wedge P(1) \wedge \ldots \wedge P(n)) \Rightarrow P(n+1)$ is true, then $\forall n : P(n)$ is true. Remember the normal induction axiom? Let $P(n)$ be a predicate. If $P(0)$ is True and $\forall n \in \mathbb{N} : (P(n) \Rightarrow P(n+1))$ is True, then $\forall n \in \mathbb{N}$ $P(n)$ is True. The difference is that you’re assuming that all the cases starting from the base case til $n$ are true, in order to prove that $P(n+1)$ is true. The Unstacking game is demonstrated: here’s a brief recap (no, actually, this is just another LaTex exercise for me)

The score one would get is (4*4)+(2*2)+(3*1)+(1*1)+(1*1)+(2*1)+(1*1) = 28. There must be a strategy to beat this, is there?

(7*1)+(6*1)+(5*1)+(4*1)+(3*1)+(2*1)+(1*1) = 28. Now one should immediately jump to the conclusion (if one is an MIT student) that all combinations lead to a score of 28. But one is not if one is reading this, so: Theorem: All strategies $S(n)$ for the Unstacking Game with $n$ starting blocks lead to the same score. Proof by strong induction: Inductive Hypothesis: $P(n)$ is the Theorem. Base Case: $S(1)$ is zero (One can’t play the game with 0 blocks). Inductive step: Assume $P(1), P(2), \ldots, P(n)$ in order to prove $P(n+1)$. With $(n+1)$ blocks, for $1 \leq k \leq n$:

Our score for $P(n+1)$ is $k(n+1-k)+P(k)+P(n+1-k)$ (think recursion, after each division of blocks each block is an instance of the Game). One has hit a dead end here, as one is trying to prove that $P(n+1)$ is dependent on $n$, not $k$. Honestly this example (IMHO) is rather haphazard, as the next step, which not so intuitively, is to make a good guess as to what $S(n)$ might be, and in classic MIT intuition style, our first guess yields $\frac{n(n-1)}{2}$. Testing a few values of $n$.. $S(2) = 1$, $S(3) = 3$, $S(4) = 6$, $S(8) = 28$. Let’s put $P(n)$ through its runs again…. Base case, where $P(n) = \frac{n(n-1)}{2}$: $P(1) = 0$. Going back to the previous expression which we derived for the score, now that we have an expression for $P(n)$: $k(n+1-k) + \frac{k(k-1)}{2} + \frac{(n+1-k)(n-k)}{2}$ Simplifying this expression (aka plugging it into WolframAlpha…) results in $\frac {n(n+1)}{2}$, which is $S(n+1)$. In the words of the professor, “The $k$ disappears.“ We have worked backwards (to my understanding), deriving an expression for the score, reaching a dead end, where we have to stop assuming ($k$), come up with an expression for $P(n)$, and filling in the blank to prove $P$(or $S$)$(n+1)$.

Proof by contradiction (aka a LaTeX test)

What is a proof by contradiction? A proof by contradiction is if $\neg P \Rightarrow F$ is true.

One assumes that a proposition P is False, and uses that to derive until a contradiction is reached, which can’t be True.

A popular example: Let’s prove that $\sqrt2$ is irrational. An irrational number is something that cannot be expanded into a fraction. (A common misconception is that Pi is $\frac{22}{7}$ and therefore rational; no it is not exactly $\frac{22}{7}$.

See http://mathworld.wolfram.com/PiFormulas.html

Assume that $\sqrt2$ is rational; such that we can represent it as $\frac{a}{b}$, where $\frac{a}{b}$ is a fraction in lowest terms.

$\Rightarrow \sqrt2 = \frac{a}{b}$ $\Rightarrow 2 = \frac{a^2}{b^2}$ $\Rightarrow 2b^2 = a^2$ $\Rightarrow 2 \mid a$ $\Rightarrow 4 \mid a^2$ $\Rightarrow 4 \mid 2b^2$ $\Rightarrow 2 \mid b^2$ $\Rightarrow 2 \mid b$ If both $a$ and $b$ are even, they are not in lowest terms, as both can be divided by 2 for further simplification. Hence we have a contradiction. $\square$

On calling su in an Android App

http://su.chainfire.eu/#how I noticed that https://github.com/koush/Superuser‘s su binary requires quotes around the target command, or else it won’t execute properly.

1
2
3
4
5
6
7
8
9
u0_a156@aries:/ $ su -c ping 8.8.8.8
su -c ping 8.8.8.8
Unknown id: 8.8.8.8
u0_a156@aries:/ $ su -c "ping 8.8.8.8"
su -c "ping 8.8.8.8"
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=3 ttl=39 time=262 ms
64 bytes from 8.8.8.8: icmp_seq=5 ttl=39 time=271 ms

The “solution” is to write the intended su -c command to a shell script file and then call it with ProcessBuilder:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
try {
String samplePingCommand = new String("su -c ""+"ping 8.8.8.8"+""");
FileOutputStream fOut = getActivity().openFileOutput("test_ping.sh", MODE_WORLD_READABLE);
OutputStreamWriter osw = new OutputStreamWriter(fOut);
osw.write(samplePingCommand);
osw.flush();
osw.close();
ProcessBuilder testPingCommand = new ProcessBuilder("sh", getActivity().getFilesDir()+"/test_ping.sh");
testPingCommand.redirectErrorStream(true);
Process startTestPingCommand = testPingCommand.start();
BufferedReader testPingCommandOut = new BufferedReader(new InputStreamReader(startTestPingCommand.getInputStream()));
String testPingCommandSingleLine;
while ((testPingCommandSingleLine = testPingCommandOut.readLine()) != null) {
/*Log.e("Ping Command Output", testPingCommandSingleLine); */
}
catch (Exception e) {
Log.e("Ping Command", "Error", e);
}

Unicode support nightmare

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×