Skip to content

Instantly share code, notes, and snippets.

View base698's full-sized avatar

Justin Thomas base698

View GitHub Profile
npm install express
# server.js
var app = require('express')();
app.post('/myform', function(req, res) {
var formData = req.body;
console.log(formData);
})
@base698
base698 / http.sh
Last active August 29, 2015 13:59
http
#!/usr/local/bin/node
var express = require('express');
var home = process.cwd();
var ONE_DAY = Math.floor(315576000000/365);
var app = express();
app.use(
express.static(home, { maxAge: ONE_DAY }));
import org.jibble.pircbot.*;
// http://www.jibble.org/pircbot.php
class GroovyBot extends PircBot {
def users = ["base698"];
public GroovyBot() {
this.setName("GroovyBot");
}
@base698
base698 / gist:5715612
Last active December 18, 2015 03:08
Something like this....
<html>
<meta charset="utf-8">
<head>
<SCRIPT LANGUAGE="JavaScript">
function textProcess(form) {
var apiCalls= [];
var textInput = form.inputbox.value;
var inputArray=textInput.split(" ");
for (i=0; i<inputArray.length; i++){
function reverse(string) {
if(string.length == 1) {
return string;
}
return string.charAt(string.length - 1) + reverse(string.slice(0, string.length - 1));
}
@base698
base698 / update-in.md
Created March 11, 2016 18:27
update-in, get-in, and assoc-in

Not using these functions is doing it wrong.

I recently went back and looked at some clojure I wrote when I was learning.

Given:

(def x {:a 1 :b {:c 3}})

So for a case like this, where I wanted to increment {:c 3} and have the change persist in x I was doing code like this:

(defn work-queue
" Work queue to process jobs with function f. Specify number of go threads "
([go-threads jobs f] (work-queue go-threads jobs f nil nil))
([go-threads jobs f cb] (work-queue go-threads jobs f nil cb) )
([go-threads jobs f notification-channel cb]
(let [work-queue (chan)
jobs-count (count jobs)
timeout-in-s 300
job-queue (chan)]
@base698
base698 / update-in.md
Last active March 11, 2016 21:17
update-in, get-in, and assoc-in

update-in, assoc-in, get-in: Not using these functions is doing it wrong

I recently went back and looked at some clojure I wrote when I was learning.

Given:

(def x {:a 1 
        :b {:c 3}})
@base698
base698 / stats.sh
Last active August 12, 2016 18:08
Find commits in a workspace for listed languages
#!/bin/bash
source_reg='\b(scala|cpp|js|java|coffee|rb|java|clj|py|groovy|html|ejs|sh|cljs)\b';
awk_counts='{
counts[tolower($1)]++
}
END {
for(type in counts) {
print(type, counts[type])
}
package io.vertx.blog.first;
import java.io.File;
import java.util.Scanner;
import io.vertx.core.AbstractVerticle;
import io.vertx.core.Future;
public class MyFirstVerticle extends AbstractVerticle {
static String data;
final static int BLOCK_SIZE = 250000;