Skip to content

Instantly share code, notes, and snippets.

View SamuelMarks's full-sized avatar
:octocat:
C > Rust > Go > TypeScript > C++

Samuel Marks SamuelMarks

:octocat:
C > Rust > Go > TypeScript > C++
View GitHub Profile
def uuid4():
"""Generate a random UUID."""
# When the system provides a version-4 UUID generator, use it.
if _uuid_generate_random:
_buffer = ctypes.create_string_buffer(16)
_uuid_generate_random(_buffer)
return UUID(bytes=_buffer.raw)
# Otherwise, get randomness from urandom or the 'random' module.
@SamuelMarks
SamuelMarks / page_count.py
Last active December 18, 2015 13:19
Python script to help me keep track of how much of the university material I have gotten through up until exams
import win32com.client # If I can be bothered, will switch to using an Open Source cross-platform API
from glob import glob
from PyPDF2 import PdfFileReader
from os import getcwd
from datetime import datetime
def pdf_page_count(filename):
curr = open(filename, "rb")
@SamuelMarks
SamuelMarks / nodejs_phantomjs_render.js
Created July 26, 2013 04:37
Google AngularJS SEO talk from July, 2013
/* render website with JS and return its rendered output
Syntax: node nodejs_phantomjs_render.js [url] [output {default=stdout}] */
var system = require('system'),
fs = require('fs'),
page = new WebPage(),
url = system.args[1],
output = system.args[2],
result;
@SamuelMarks
SamuelMarks / Added-support-for-the-BSDs-and-Solaris-endianness.patch
Created November 8, 2013 11:14
Endianness checks replacement for LLVM (posted to llvm-commits)
From 346740535fe71b34218fa1137a14e6ed8f6833ae Mon Sep 17 00:00:00 2001
From: Samuel Marks <samuelmarks@gmail.com>
Date: Fri, 8 Nov 2013 22:04:06 +1100
Subject: [PATCH] Added support for the BSDs and Solaris endianness; code from
ChromiumOS project (LevelDB ppl)
---
include/llvm/Support/Host.h | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
\documentclass[a4paper,11pt]{article}
\usepackage[english]{babel}
\usepackage{amsmath,amssymb,cancel,array,graphics,enumerate,fancyhdr,graphviz,psfrag,minted}
\usepackage{ucs}
\usepackage[utf8x]{inputenc}
\title{}
\author{Samuel Marks}
\begin{document}
/tmp/a$ gulp karma
[16:05:10] Using gulpfile /tmp/a/gulpfile.js
[16:05:10] Starting 'eslint'...
[16:05:10] Starting 'jsonlint'...
[16:05:11] Finished 'jsonlint' after 294 ms
[16:05:11] Finished 'eslint' after 450 ms
[16:05:11] Starting 'linting'...
[16:05:11] Finished 'linting' after 12 μs
[16:05:11] Starting 'karma'...
29 12 2015 16:05:11.367:WARN [watcher]: Pattern "/tmp/a/app/**/templates/*.html" does not match any file.
@SamuelMarks
SamuelMarks / pyman
Last active January 2, 2016 04:09 — forked from ekimekim/pyman
#!/usr/bin/env python
from sys import argv, exit
if __name__ == '__main__':
if len(argv) < 2:
print "USAGE: {0} MODULE [SYMBOL]".format(argv[0])
print "Open help() for given module, or given symbol from module"
exit(1)
@SamuelMarks
SamuelMarks / diff -r example2 generator-m-ionic-demo
Created January 6, 2016 13:12
diff -r example2 generator-m-ionic-demo
diff -r example2/.yo-rc.json generator-m-ionic-demo/.yo-rc.json
4,6c4,6
< "appName": "example2",
< "appId": "com.company.example2",
< "ionicCss": false,
---
> "appModule": "myProject",
> "appName": "My Project",
> "appId": "com.company.project",
12a13
@SamuelMarks
SamuelMarks / upgrade_all_pip_packages.py
Last active February 8, 2016 06:24
Upgrade all packages using pip
#!/usr/bin/env python
from __future__ import print_function
from sys import stderr
from pip import get_installed_distributions
from pip.commands import install
from pip.exceptions import InstallationError
mongoose.connect = MongooseThenable {
connections:
[ NativeConnection {
base: [Object],
collections: {},
models: {},
config: [Object],
replica: false,
hosts: null,
host: '192.168.2.2',