Skip to content

Instantly share code, notes, and snippets.

View selfup's full-sized avatar
💻
doing the most

Regis Boudinot selfup

💻
doing the most
View GitHub Profile
@selfup
selfup / opsstuff.md
Last active September 1, 2016 01:00

Ruby

The students will need to learn a scripting language that can help them organize bash scripts.

Ruby has an excellent backtick api to execute shell commands.

In pry:

puts `echo "hello from ruby"`
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
</head>
<body>
<h1>My First Heading</h1>
<p>My first paragraph.</p>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>

Iterators

What is the difference between forEach and map in JS?

forEach:

const arr = [1, 2, 3];

const eachExample = () => arr.forEach(e => e);
class Rubux
attr_reader :state
def initialize(state = {}, actions = {})
@state = state
@actions = actions
end
def dispatch(key, value)
return @state = @state.merge(@actions[key].(state, value)) if @actions[key]
@selfup
selfup / ll.js
Last active September 5, 2017 18:56
class Node {
constructor(data = null, next_node = null) {
this.data = data;
this.next_node = next_node;
}
}
class List {
constructor() {
this.head = new Node();
// here we import 'html' instead of just 'h'
import { html } from 'hyperapp';
// now we use the 'html`` template tag literal
const view = (model, msg) => (html`
<div class="counter">
<h1>Welcome to the hyperapp-one boilerplate!</h1>
<p><em>With JSX</em></p>
<hr class="line-break" />
<section>
class EmailField extends Component {
constructor() {
super();
this.state = {
email: '',
};
}
handleClick = (e) => {
this.props.dispatch('SOMETHING', { email: e.target.innerText }):
macro_rules! actions({
$( $action: expr => $function: expr ), + } => {{
let mut store = ::std::collections::HashMap::new();
$(store.insert($action as &str, $function as Box<Fn(&str)>);) + store
}};
);
fn main() {
let actions = actions!{
"foo" => Box::new(|arg: &str| println!("foo {}", arg)),
fn cluster(trimmed: i64) {
let range: Vec<i64> = (0..trimmed + 1).collect();
range.par_iter()
.map(|i| thread::spawn(move || run(i.to_le())))
.map(|runner| runner.join());
}
const express = require('express')
const cors = require('cors')
const bodyParser = require('body-parser')
const app = express()
app.use(bodyParser.urlencoded({ extended: true }))
app.use(cors())
app.post('/dev_log', function (req, res, next) {