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:
| {-# 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) |
| 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 |
| {- | An EDSL for defining and printing JSON values | |
| -} | |
| import Data.List (intercalate) | |
| ---------------- | |
| -- JSON Model -- | |
| ---------------- | |
| -- | The JSONValue data type represents a JSON Value |
| 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); |
| # 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 |
| # 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: |
| 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 |
I hereby claim:
To claim this, I am signing this object:
| /* You are given an n x n array P[i,j] with i and j indices that range from 0 to n-1. There is a number in each location of P[i,j] that can be negative or positive. You start with the index pair [n-1, n-1] and are free to traverse any path(according to the following two rules) that ends at [0,0]. | |
| **Rule 1:** At any location [i,j] you can decrement either one of the indices or both. So from [i,j] you can go to [i-1, j] or [i,j-1] or [i-1,j-1]. However no index is allowed to go below 0(obviously). | |
| **Rule 2:** When an index reaches 0, it stays at 0. | |
| Again, there is a number stored at each location of P[i,j]. The value of a path is the sum of the P[i,j] values for the indices used by the path. | |
| Present a recursive solution that solves for the greatest possible value path among all such paths. In other words find **Best(i, j)** which is the value of the best**(maximum sum)** path from location (i,j) to (0,0). |
| /** | |
| * Evaluate a basic mathematical expression | |
| * | |
| * This is my 2nd attempt at this problem. | |
| * For the 1st attempt, please look at the code | |
| * commented at the bottom. | |
| * | |
| * Did some research on how to tackle this problem, | |
| * came up to using Reverse Polish Notation. | |
| * |