Skip to content

Instantly share code, notes, and snippets.

View jroweboy's full-sized avatar

James Rowe jroweboy

  • C wage slave :^)
View GitHub Profile
@jroweboy
jroweboy / limitdolby.sh
Created April 6, 2013 23:12
Simple cpulimit script that searches for the pid of a program and uses cpulimit on that
#!/bin/sh
output=`ps aux | grep A[x]on`
set -- $output
pid=$2
sudo cpulimit -p $pid -l 30
# if anyone feels like making this more robust be my guest :)
@jroweboy
jroweboy / gist:9440061
Created March 8, 2014 22:34
Simple reverse routing
<html><head><title>test</title></head>
<body>
<div id="nav-bar">
<ul>
<li>
<a href="{{???}}">Home</a> // what is the url that goes there? /index right? What if I change the route though...
</li>
<li>
<a href="{{???}}">About us</a> // maybe about us is at /info But then my boss says he wants it at /about
// Now do I have to update all the places that reference /about?
@jroweboy
jroweboy / rwarc.rs
Created March 11, 2014 02:46
this compiles
extern crate sync;
extern crate collections;
use sync::RWArc;
use collections::hashmap::HashMap;
fn main() {
let mut test = RWArc::<HashMap<~str,~str>>::new(
HashMap::<~str,~str>::new()
);
@jroweboy
jroweboy / error
Last active August 29, 2015 13:57
error message
rustc --crate-type=dylib,rlib -L lib src/oxidize.rs --out-dir build/
src/oxidize.rs:86:9: 86:37 error: type `sync::arc::RWArc<~route::Router:Send+Freeze>` does not implement any method in scope named `get`
src/oxidize.rs:86 self.conf.get().router.get().route(my_request, response);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
error: aborting due to previous error
make: *** [build/liboxidize-a719aadf-0.0.so] Error 101
@jroweboy
jroweboy / next.rs
Created March 14, 2014 03:29
no method next on vector
// snip
pub fn new(routes: ~[RegexRoute]) -> RegexRouter {
let mut rev_map = HashMap::<~str,~str>::new();
for route in routes {
match route {
// snip
error: type `&mut ~[route::regexrouter::RegexRoute]` does not implement any method in scope named `next`
tmp/recursive.rs:19:16: 19:38 error: borrowed value does not live long enough
tmp/recursive.rs:19 curr = curr.unwrap().children.find_or_insert(a.clone(), Some(Node::new(a.clone())));
^~~~~~~~~~~~~~~~~~~~~~
tmp/recursive.rs:15:11: 21:2 note: reference must be valid for the block at 15:10...
tmp/recursive.rs:15 fn main() {
tmp/recursive.rs:16 let v = ~[~"Hello", ~"Tree", ~"World"];
tmp/recursive.rs:17 let mut curr = &mut Some(Node::new(~"Testing"));
tmp/recursive.rs:18 for a in v.iter() {
tmp/recursive.rs:19 curr = curr.unwrap().children.find_or_insert(a.clone(), Some(Node::new(a.clone())));
tmp/recursive.rs:20 }
@jroweboy
jroweboy / errormsg
Last active August 29, 2015 13:57
lifetimes
struct.rs:19:9: 21:10 error: cannot infer an appropriate lifetime due to conflicting requirements
struct.rs:19 |Request| -> Response {
struct.rs:20 Response { data: self.database.to_owned() }
struct.rs:21 }
struct.rs:18:56: 22:6 note: first, the lifetime cannot outlive the block at 18:55...
struct.rs:18 fn index<'b>(&'b self) -> 'a |Request| -> Response {
struct.rs:19 |Request| -> Response {
struct.rs:20 Response { data: self.database.to_owned() }
struct.rs:21 }
struct.rs:22 }
@jroweboy
jroweboy / BattleMode.java
Created April 29, 2014 00:55
A very simple to create a world border in minecraft 1.8 (until the world border command works right)
import java.awt.AWTException;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.awt.event.KeyEvent;
/**
*
* @author b0b & Kilvean
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jroweboy
jroweboy / error
Last active August 29, 2015 14:01
For uint
temp.rs:2:51: 2:79 error: mismatched types: expected `~[[f32, .. 1024], .. 1024]` but found `~[[<generic float #0>, .. 1024]]` (expected vector but found vector)
temp.rs:2 let mut rows : Box<[[f32, ..1024], ..1024]> = box [[50.0, ..1024], ..1024];
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
error: aborting due to previous error