Skip to content

Instantly share code, notes, and snippets.

import ctypes
libc = ctypes.CDLL("libc.so.6", use_errno = True)
if __name__ == '__main__':
set_rv = libc.prctl(22, 2, 0)
set_errno = ctypes.get_errno()
print("prctl(PR_SET_SECCOMP, 2, NULL) = %d errno %d" % (set_rv, set_errno))
get_rv = libc.prctl(21)
print("prctl(PR_GET_SECCOMP) = %d" % get_rv)
@jld
jld / gist:33e4b421f3a963863735
Created March 9, 2016 19:37
Git is having a bad day.
# (This is a deflated git tree object.)
$ hexdump -C .git/objects/59/612c54dadcc3146d5026dae9e6fa674498ee07
00000000 78 01 2b 29 4a 4d 55 30 34 33 65 30 34 30 30 33 |x.+)JMU043e04003|
00000010 31 51 f0 4d cc 4e 4d cb cc 49 65 98 99 96 59 a1 |1Q.M.NM..Ie...Y.|
00000020 3b 6f bd cd 92 f3 3e a7 df 4a ed bb b0 d4 46 b7 |;o....>..J....F.|
00000030 0b aa 26 37 31 2f 33 2d b5 b8 44 2f 37 8f 61 de |..&71/3-..D/7.a.|
00000040 c6 ff 05 5e 0c ff a3 3e 3c 57 ed 5a eb 2a 79 5e |...^...><W.Z.*y^|
00000050 e0 e8 b9 17 50 65 a5 25 99 39 f1 e9 25 20 85 c9 |....Pe.%.9..% ..|
00000060 c9 0c 6e 1b d3 fc ed a2 db 42 57 4f f9 be f7 fa |..n......BWO....|
00000070 51 a5 e2 d6 9d 77 3c 90 15 96 96 a4 59 c4 97 e6 |Q....w<.....Y...|
$ set -- foo bar
$ for x in "$@ X"; do echo $x; done
foo
bar X
$ X=X
$ for x in "$@ $X"; do echo $x; done
foo
bar X
sh-3.2$ set -- foo bar
use std::thread;
struct Bees;
impl Drop for Bees {
fn drop(&mut self) { panic!("Not the bees!"); }
}
struct Msg(&'static str);
impl Drop for Msg {
fn drop(&mut self) { println!("Destructor: {}", self.0); }
#!/bin/sh
[ $# -gt 0 ] || set -- HEAD
eval set -- '"$@^..$'$#\"
git format-patch --stdout -p -U8 --subject-prefix= --minimal "$@" | git-patch-to-hg-patch
@jld
jld / errors.txt
Last active December 14, 2015 21:51
In which borrowck errors are unhelpful.
src/main.rs:6:28: 6:29 error: cannot infer an appropriate lifetime for automatic coercion due to conflicting requirements [E0495]
src/main.rs:6 let caps = re.captures(s).unwrap();
^
src/main.rs:6:28: 6:29 note: first, the lifetime cannot outlive the expression at 6:27...
src/main.rs:6 let caps = re.captures(s).unwrap();
^
src/main.rs:6:28: 6:29 note: ...so that auto-reference is valid at the time of borrow
src/main.rs:6 let caps = re.captures(s).unwrap();
^
src/main.rs:6:16: 6:30 note: but, the lifetime must be valid for the method call at 6:15...
import os,ctypes,struct,errno,sys
CLONE_NEWIPC = 0x08000000
CLONE_NEWUSER = 0x10000000
CLONE_NEWNET = 0x40000000
start_uid = os.getuid()
start_gid = os.getgid()
c = ctypes.CDLL("libc.so.6", use_errno = True)
diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp
index ab063db..40a35ce 100644
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -4495,12 +4495,12 @@ XRE_InitCommandLine(int aArgc, char* aArgv[])
// get the canonical version of the binary's path
nsCOMPtr<nsIFile> binFile;
rv = XRE_GetBinaryPath(aArgv[0], getter_AddRefs(binFile));
- if (NS_FAILED(rv))
+ if (NS_WARN_IF(NS_FAILED(rv)))
@jld
jld / gist:1800b827d7a3f05d6b16
Created April 23, 2015 02:11
In which we fail to O_PONIES
jld@nimbostratus$ adb shell ls -l /data/b2g/mozilla
drwx------ root root 2015-04-23 02:09 Crash Reports
drwx------ root root 2015-04-23 02:09 l82onhkd.default
-rw-r----- root root 104 2015-04-23 02:09 profiles.ini
jld@nimbostratus$ adb shell ls -l /data/b2g/mozilla
drwx------ root root 2015-04-23 02:09 Crash Reports
drwx------ root root 2015-04-23 02:09 l82onhkd.default
-rw-r----- root root 0 2015-04-23 02:09 profiles.ini
jld@nimbostratus$ adb shell ls -l /data/b2g/mozilla
drwx------ root root 2015-04-23 02:09 Crash Reports
#!/usr/bin/env python
import os, sys, bisect, re
class Module:
def __init__(self, name):
self.name = name
self.files = []
self.funcs = []
self.lines = []