Skip to content

Instantly share code, notes, and snippets.

View sohang3112's full-sized avatar
:octocat:

Sohang Chopra sohang3112

:octocat:
View GitHub Profile
@ghoseb
ghoseb / ns-cheatsheet.clj
Last active May 20, 2024 13:01 — forked from alandipert/ns-cheatsheet.clj
Clojure ns syntax cheat-sheet
;;
;; NS CHEATSHEET
;;
;; * :require makes functions available with a namespace prefix
;; and optionally can refer functions to the current ns.
;;
;; * :import refers Java classes to the current namespace.
;;
;; * :refer-clojure affects availability of built-in (clojure.core)
;; functions.
@huyng
huyng / reflect.py
Created February 7, 2011 17:57
A simple echo server to inspect http web requests
#!/usr/bin/env python
# Reflects the requests from HTTP methods GET, POST, PUT, and DELETE
# Written by Nathan Hamiel (2010)
from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler
from optparse import OptionParser
class RequestHandler(BaseHTTPRequestHandler):
def do_GET(self):
@lorn
lorn / gist:976873
Created May 17, 2011 17:12 — forked from medecau/opcp.md
Online Programming Contests and Puzzles
@gerjantd
gerjantd / get-mygists.sh
Created July 20, 2012 09:23
Github: API v3 call for retrieving my public gists
#!/bin/bash
mkdir mygists
cd mygists
curl -u "gerjantd" https://api.github.com/gists | json_xs > mygists.json
cat mygists.json | grep "\"id\"" | awk -F "\"" '{print $4}' > repos
for g in `cat repos`; do git clone git@gist.github.com:$g.git gist-$g; done
@uho
uho / gist:3451894
Created August 24, 2012 15:15
Simple Forth example showing the handling of string and number input/output
20 chars Constant namestring-len
Create namestring namestring-len allot
: input ( buf-addr buf-len prompt-addr promt-len -- buf-add len )
\ prompt user for string
cr type over swap accept ;
: get-age ( -- n )
0.
BEGIN ( d )
@jbclements
jbclements / sliders.rkt
Created October 24, 2012 22:02
A simple example of using Racket and 2htdp/universe to create a bunch of sliders on the screen
(require 2htdp/universe)
(require 2htdp/image)
; Copyright 2012, John Clements (clements@brinckerhoff.org)
;
; Licensed under the Apache License, Version 2.0 (the "License");
; you may not use this file except in compliance with the License.
; You may obtain a copy of the License at
;
; http://www.apache.org/licenses/LICENSE-2.0
from fabric.api import local
import pip
def freeze ():
local("pip freeze > requirements.txt")
local("git add requirements.txt")
local("git commit -v")
def upgrade ():
for dist in pip.get_installed_distributions():
@honza
honza / gist.md
Created June 30, 2013 23:03
Clojure vs Haskell

Haskell vs Clojure

The JSON data is in the following format

{
    "Genesis": {
        "1": {
            "1": "In the beginning..." ,
            "2": "..."
@scy
scy / opening-and-closing-an-ssh-tunnel-in-a-shell-script-the-smart-way.md
Last active June 10, 2024 09:43
Opening and closing an SSH tunnel in a shell script the smart way

Opening and closing an SSH tunnel in a shell script the smart way

I recently had the following problem:

  • From an unattended shell script (called by Jenkins), run a command-line tool that accesses the MySQL database on another host.
  • That tool doesn't know that the database is on another host, plus the MySQL port on that host is firewalled and not accessible from other machines.

We didn't want to open the MySQL port to the network, but it's possible to SSH from the Jenkins machine to the MySQL machine. So, basically you would do something like

ssh -L 3306:localhost:3306 remotehost

@rssh
rssh / OSDN2013_Forth_5
Created October 10, 2013 05:57
example of getting square root in forth
: sqrt-closer (square guess -- square guess adjustment) 2dup / over - 2 / ;
: sqrt ( square -- root ) 1 begin sqrt-closer dup while + repeat drop nip ;