Skip to content

Instantly share code, notes, and snippets.

View spwilson2's full-sized avatar

Sean spwilson2

  • Droogle
  • Mountain View, CA
View GitHub Profile
package test;
public class Scope {
// public static void main(String [] args) {
//
// String word = "hello";
// sayGoodbye();
// System.out.println(word);
//
// Create a file named "ChickenRanch (notice that this class is typoed).
public class ChikenRanch;
/*/*
// This program named ChickenRanch.java should print print
// the following including quotes:
// "Ranch it up!"
//
*/*/
public static void main(String[] args) {
@spwilson2
spwilson2 / thread-affinity.py
Created April 3, 2018 00:28
Quick mess around at making thread based invoke/event loops on object methods.
import inspect
import threading
import queue
MANGLE_LEN = 256 # magic constant from compile.c
def mangle(name, klass):
if not name.startswith('__'):
return name
if len(name) + 2 >= MANGLE_LEN:
#include <thread>
#include <iostream>
int main() {
std::thread other([]{ std::cout << "Hello." << std::endl; });
other.join();
return 0;
}
@spwilson2
spwilson2 / custom_sheduler.py
Created June 27, 2017 16:11 — forked from wronglink/custom_sheduler.py
Custom pytest-xdist scheduler that groups tests by TestCase
import itertools
from xdist.dsession import LoadScheduling
"""
Custom scheduler implementation that prevents running in parallel tests, that belong same class (TestCase).
Custom scheduler support implemented in this PR: https://github.com/pytest-dev/pytest-xdist/pull/89
"""
class GroupedLoadScheduling(LoadScheduling):
def check_schedule(self, node, duration=0):
# This is how you would normally do a keyword argument
def normal_function(keyword_arg=None):
print(keyword_arg)
normal_function(keyword_arg='hello world')
# Function can take any number of keyword arguments, we might do this if we are lazy and don't want to
# specify an interface
def function(**kwargs):
@spwilson2
spwilson2 / quickpatch.py
Last active June 12, 2017 22:16
Used to change bound member functions with bind to their lambda equivalent.
import sys
import re
match_regex = re.compile(r"(?P<bound_capture>std::bind\((?P<bound_function>&[\w:]+),[\s]+this\),)")
lambda_replace = r"[this]{ \g<bound_function>(); },"
file_list = sys.argv[1]
#!/bin/bash
# NOTE: Script assumes that your origin is set to https://github.com/multifacet/gem5
git checkout origin/sean/merging/events
scons -j20 build/ARM/gem5.opt
./build/ARM/gem5.opt --debug-flags=All configs/learning_gem5/part1/simple.py &> all-merging-events.debug
git checkout origin/master
scons -j20 build/ARM/gem5.opt
@spwilson2
spwilson2 / master-results.txt
Last active June 8, 2017 17:59
scons build/ARM/tests/debug/quick/se
[?1034hscons: Reading SConscript files ...
Checking for C header file Python.h... (cached) yes
Checking for C library pthread... (cached) yes
Checking for C library dl... (cached) yes
Checking for C library util... (cached) yes
Checking for C library m... (cached) yes
Checking for C library python2.7... (cached) yes
Checking for accept(0,0,0) in C++ library None... (cached) yes
Checking for zlibVersion() in C++ library z... (cached) yes
Checking for GOOGLE_PROTOBUF_VERIFY_VERSION in C++ library protobuf... (cached) yes
(require 'package)
(add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/"))
(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/"))
(add-to-list 'package-archives '("melpa-stable" . "http://stable.melpa.org/packages/"))
(setq package-enable-at-startup nil)
(package-initialize)
(unless (package-installed-p 'use-package)