I hereby claim:
- I am christiansakai on github.
- I am christiansakai (https://keybase.io/christiansakai) on keybase.
- I have a public key whose fingerprint is 74E8 F9E2 876B F233 180C 298F B187 A3C8 EE48 EE85
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
| defmodule Choir do | |
| @voices ["Bells", "Good News", "Pipe Organ", "Cellos", "Bad News"] | |
| # Concurrency | |
| def sing do | |
| {:ok, pid} = Singer.start_link | |
| Enum.map 1..20, fn x -> | |
| voice = Enum.random @voices | |
| Singer.sing_it pid, voice |
| # You have your csv data and it looks like so... It's in a file named "my_data.csv" and we want to import it into a table named "my_things". | |
| "1", "Something", "0.50", "2013-05-05 10:00:00" | |
| "2", "Another thing", "1.50", "2013-06-05 10:30:00" | |
| # Now you want to import it, go to the command line and type: | |
| $ PGPASSWORD=PWHERE psql -h HOSTHERE -U USERHERE DBNAMEHERE -c "\copy my_things FROM 'my_data.csv' WITH CSV;" | |
| # Voila! It's impoted. Now if you want to wipe it out and import a fresh one, you would do this: |
| # How to Debug CORS | |
| # Use this Shell script for example. | |
| # * Intentionally add the wrong Origin, e.g. http://localhost below | |
| # but <AllowedOrigin>http://somedomain.com</AllowedOrigin> in your CORS policy. | |
| # * Run this script. The `--verbose` should give you back the response. | |
| # * Check if the CORS policy is being returned with response. | |
| # For example, the Access-Control-Allow-Origin should give you back your Origin that you used below. | |
| # The actual resource (e.g., CSS, JS, font, image) files will still be returned because this is a non-browser request. | |
| # (Keep in mind that CURL, POSTMAN, or any other non-browser related request |
| BEGIN; | |
| LOCK table_name; | |
| ALTER TABLE table_name ADD COLUMN column_new column_type; | |
| UPDATE table_name SET column_new = column_name; | |
| ALTER TABLE table_name DROP column_name; | |
| ALTER TABLE table_name RENAME column_new TO column_name; | |
| END; | |
| -- varchar -> integer | |
| -- UPDATE cpvbeacon_dev SET column_new = CAST (nullif(column_name, '') AS INTEGER); |
| {- | An EDSL for defining and printing JSON values | |
| -} | |
| import Data.List (intercalate) | |
| ---------------- | |
| -- JSON Model -- | |
| ---------------- | |
| -- | The JSONValue data type represents a JSON Value |
| module Main where | |
| import System.IO (hSetBuffering, stdin, BufferMode(NoBuffering)) | |
| import Control.Monad (unless) | |
| import System.Process (system) | |
| import System.Environment (getArgs) | |
| stepSize :: Int | |
| stepSize = 30 |
| {-# LANGUAGE LambdaCase #-} | |
| -- http://gilmi.xyz/post/2016/10/14/lisp-to-js | |
| module Main where | |
| import Control.Applicative (Alternative, empty, (<|>)) | |
| import Control.Arrow (first, (***)) | |
| import Data.Bool (bool) | |
| import Data.List (intercalate) |
| {-# LANGUAGE DeriveDataTypeable #-} | |
| {-# LANGUAGE LambdaCase #-} | |
| import Control.Monad | |
| import Data.Data | |
| import Data.Typeable | |
| import System.IO | |
| import System.Exit | |
| type Stack = [Lit] |
| "use strict"; | |
| // Channel is a simple object that can be used for | |
| // CSP-style concurrency in Javascript. In JS code, | |
| // the act of taking a value from a channel looks | |
| // like a blocking call and therefore is not appropriate | |
| // for single-process/single-thread environments like | |
| // NodeJS. To address that, Channel produces promises | |
| // for values. | |
| // |