Skip to content

Instantly share code, notes, and snippets.

{-|
- Example of using free constructions to build a flexible little compiler.
-
- The goal here is not necessarily efficiency but readability and flexibility.
-
- The language grammar is represented by an ADT; however, instead of
- recursively referring to itself it instead references a type variable.
-
- We derive instances of 'Functor' and 'Traversable' for this type.
-
@dfletcher
dfletcher / tsws
Last active July 21, 2018 12:47
Totally simple web server using Bash and netcat (nc)
Moved to a proprer repositoy, TSWS is a real boy now!
https://github.com/dfletcher/tsws
PRs welcomed.
@sogko
sogko / ClickOutsideListener.react.js
Last active January 1, 2018 13:14
A pure ES6-style composable React component that handles clicks outside of a HTML node / React component. (No mixins)
/*
A pure ES6-style composable React component that handles clicks outside of a HTML node.
This is for those who prefers composibility over mixins.
Simply drop-in the event listener component into your React component.
Adapted from: https://github.com/Pomax/react-onclickoutside
*/
var React = require('react');
anonymous
anonymous / Grid.hs
Created December 4, 2014 14:41
GridZipper
{-# LANGUAGE RecordWildCards #-}
module Grid where
import Data.Maybe
newtype Grid a = Grid { unGrid :: [[a]] }
type ListZipper a = ([a], a, [a])
@vishalzambre
vishalzambre / curl.sh
Last active October 2, 2021 02:30
Using devise gem sign_in & sign_out API's with sessions
#login
curl -v -H "Accept: application/json" -H "Content-type: application/json" -X POST -d ' {"user":{"email":"<email>","password":"<passwd>"}}' http://localhost:3000/api/v1/sign_in.json
#logout
curl -v -H "Accept: application/json" -H "Content-type: application/json" -X DELETE http://localhost:3000/api/v1/sign_out.json?auth_token=<token>
@jonnii
jonnii / default.ps1
Created May 7, 2012 14:41
Creating a click once package using mage and powershell
task PrepareClickOnce {
write-host 'Add mage to our path'
$env:path += ";C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools"
write-host "Preparing install directory"
$installersRoot = '..\installers\app'
if (test-path $installersRoot) {
Write-Host "Cleaning installers root"
rm -r -force $installersRoot > $null
@mattpodwysocki
mattpodwysocki / dragdrop.html
Created March 22, 2012 04:54
Drag and Drop in RxJS
<!DOCTYPE html>
<head>
<script src="http://code.jquery.com/jquery-latest.js" type="text/javascript"></script>
<script src="rx.min.js" type="text/javascript"></script>
<script src="rx.jquery.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
var dragTarget = $('#dragTarget')
@acwright
acwright / gist:1944639
Created February 29, 2012 21:40
Sinatra / ActionMailer / Sendgrid / Heroku
require 'sinatra'
require 'action_mailer'
class Mailer < ActionMailer::Base
def contact
mail(
:to => "test@example.com",
:from => "test@example.com",
:subject => "Test") do |format|
format.text
@sinisterchipmunk
sinisterchipmunk / LICENSE
Last active October 23, 2024 21:10
tar, gzip, and untar files using ruby in memory without tempfiles
Copyright (C) 2011 by Colin MacKenzie IV
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
@danielbeardsley
danielbeardsley / acts_as_sequential.rb
Created April 4, 2011 23:10
Adds .previous and .next named scopes to your Active Record model, treating the records in your database like a sequential list with an order of your choosing.
# Adds .previous and .next class methods to your model treating the records in your database like a sequential list
#
# Put this in your model definition:
# acts_as_sequential :column => :created_at # you can also use the :dir => 'DESC' option (ASC is the default)
#
# Then use it like this:
# Model.next(current_record) -> next record in sequence
# Model.other_named_scope.previous(current_record) -> previous record in sequence
#