Skip to content

Instantly share code, notes, and snippets.

View jessta's full-sized avatar

Jesse McNelis jessta

View GitHub Profile
@jessta
jessta / server.py
Last active October 3, 2022 03:26 — forked from martijnvermaat/server.py
SimpleHTTPServer with history API fallback
#!/usr/bin/env python
import os
import sys
import urllib
import http.server
class Handler(http.server.SimpleHTTPRequestHandler):
def do_GET(self):
urlparts = urllib.parse.urlparse(self.path)
@jessta
jessta / main.elm
Last active December 4, 2019 02:46
Simple Elm SPA example
module Main exposing (Model, Msg(..), about, home, main, routes, update, view)
import Browser
import Browser.Navigation as Nav
import Html exposing (..)
import Html.Attributes exposing (..)
import Url
import Dict
@jessta
jessta / main.elm
Created October 4, 2016 03:03
elm-style-animation example
module Main exposing (..)
import Animation exposing (px)
import Html exposing (Html, div, text)
import Html.App as App
import Html.Attributes exposing (style)
main =
App.program
@jessta
jessta / application.js
Created April 27, 2014 05:04
Server side rendering with rails and react
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
@jessta
jessta / hello.c
Created March 29, 2012 00:44
Go hello word binary size
int main(){
write(1, "hello world\n", 12);
}
/*
[jessta@book ~]$ gcc -static -Os hello.c
[jessta@book ~]$ du -h ./a.out
636K ./a.out
*/
@jessta
jessta / safehttp.go
Created February 20, 2012 16:25
Remotely safely shutdown a Go HTTP server
package main
import "net/http"
import "net"
import "sync"
var lis net.Listener
func main(){
var err error
// make our own listener
@jessta
jessta / gist:1808898
Created February 12, 2012 14:53 — forked from notedit/gist:1808849
test_server
package main
import (
"gogobservice"
"net/rpc"
"net"
"log"
)
func main() {
{
process := make(chan *feat.Feature)
buffer := make(chan *feat.Feature, 1000)
wg := new(sync.WaitGroup)
if *cores < 2 {
*cores = 2
}
for i := 0; i < *cores-1; i++ {
go func(){wg.Add(1); processServer(intervalTree, process, buffer); wg.Done()}
}
func Launch(vbox *VBoxSpec, statusch chan<- *VmStatus, quitch <-chan bool) {
go func() {
vboxPath := main.Config["VboxPath"]
vboxHeadlessBin := fmt.Sprintf("%s/VBoxHeadless", vboxPath)
statusch <- VmStatus{vbox, VMSTATUS_LAUNCHING}
var stdoutFilePtr *File
package main
import "net"
import "fmt"
func main(){
addr,err := net.ResolveTCPAddr("127.0.0.1:6000");
if addr == nil {
fmt.Printf("resovle addr: %s\n", err.String());
}
listener,err := net.ListenTCP("tcp",addr);