This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
doug:rust-libs doug$ cat junk.rs | |
#![crate_id = "junk#0.1"] | |
use std::libc::c_int; | |
#[no_mangle] | |
pub extern fn dothing(a: c_int, b:c_int) -> c_int { | |
return a + b; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <stdbool.h> | |
#include <string.h> | |
#include <errno.h> | |
#include <unistd.h> | |
#include <sys/mman.h> | |
#include <sys/stat.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// cargo-deps: lazy_static | |
#[macro_use] extern crate lazy_static; | |
macro_rules! declare_array { | |
// INTERNAL | |
// last element (proceed to output) | |
(@parse $size:expr, ($val:expr) -> [$($accs:expr),*] $thru:tt) => { | |
declare_array!(@output $size + 1usize, [$($accs,)* $val] $thru); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let request_url = "https://some.api/path.json" | |
let client = Client::new(); | |
let mut res = client.get(&request_url).send().unwrap(); | |
assert_eq!(res.status, hyper::Ok); | |
println!("Reading body.."); | |
let mut res_body = String::new(); | |
let result = res.read_to_string(&mut res_body).unwrap(); | |
println!("Done"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#variation of http://urbangiraffe.com/2011/08/13/remote-editing-with-sublime-text-2/ that adds creating new folders remotely. | |
import sublime_plugin, os | |
class RemoteEdit(sublime_plugin.EventListener): | |
def on_post_save(self, view): | |
remote = { "/Users/jijo/work/project": ["/usr/bin/scp", None, "user@server", "~/project/", None] } | |
for dirname, target in remote.iteritems(): | |
if view.file_name().startswith( dirname ): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[post("/tablet-reg-mode-status")] | |
fn reg_mode_status() -> Res<bool> { | |
ok(REGISTER_MODE.load(Ordering::Relaxed)) | |
} | |
#[post("/tablet-reg-mode-toggle")] | |
fn reg_mode_toggle(_me: Admin) -> Res<bool> { | |
for { | |
let old = REGISTER_MODE.load(Ordering::SeqCst); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import gym | |
from gym.spaces import Discrete, Box | |
from gym.wrappers import Monitor | |
from keras.models import Sequential | |
from keras.layers import Dense, Activation, Flatten | |
# ================================================================ | |
# Policies |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<head> | |
<!-- <base href="https://polygit.org/polymer+1.7.0/components/"> --> | |
<base href="https://cdn.rawgit.com/download/polymer-cdn/1.7.0/lib/"> | |
<script src="webcomponentsjs/webcomponents-lite.min.js"></script> | |
<link rel="import" href="polymer/polymer.html"> | |
<link rel="import" href="paper-tabs/paper-tabs.html"> | |
<link rel="import" href="paper-tabs/paper-tab.html"> | |
<link rel="import" href="iron-pages/iron-pages.html"> | |
</head> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::cell::UnsafeCell; | |
use std::ops::*; | |
use std::marker::PhantomData; | |
pub struct DefaultTag {} | |
pub struct SyncCell<'cc, T> { | |
unsafe_cell: UnsafeCell<T>, | |
phantom_borrow_creator: PhantomData<&'cc ()>, | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extern crate clap; | |
use clap::{App,Arg}; | |
fn main() { | |
let m = App::new("My Program") | |
.arg( | |
Arg::with_name("demo").short("d") | |
) | |
.arg( | |
Arg::with_name("rest") |
OlderNewer