Skip to content

Instantly share code, notes, and snippets.

View dvliman's full-sized avatar

David Liman dvliman

View GitHub Profile
@dvliman
dvliman / gist:10402435
Created April 10, 2014 17:02
ruby $ global variable
$: (Dollar Colon) is basically a shorthand version of $LOAD_PATH. $: contains an array of paths that your script will search through when using require.
$0 (Dollar Zero) contains the name of the ruby program being run. This is typically the script name.
$* (Dollar Splat) is basically shorthand for ARGV. $* contains the command line arguments that were passed to the script.
$? (Dollar Question Mark) returns the exit status of the last child process to finish.
$$ (Dollar Dollar) returns the process number of the program currently being ran.
$~ (Dollar Tilde) contains the MatchData from the previous successful pattern match.
$1, $2, $3, $4 etc represent the content of the previous successful pattern match.
$& (Dollar Ampersand) contains the matched string from the previous successful pattern match.
$+ (Dollar Plus) contains the last match from the previous successful pattern match.
$` (Dollar Backtick) contains the string before the actual matched string of the previous successful pattern match.
{:assetMainType "EQUITY",
:assetSubType "COE",
:callExpDateMap {},
:daysToExpiration 4.0,
:dividendYield 0.0,
:interestRate 3.8630000000000004,
:interval 0.0,
:isChainTruncated false,
:isDelayed false,
:isIndex false,
(weekly-csp
(->> (accounts)
first
:securitiesAccount
:currentBalances
:buyingPowerNonMarginableTrade)
["HOOD" "COIN" "TSM"])
{:high ["HOOD" 104.85 105.0 4.97 2 1416],
:low ["HOOD" 104.85 104.0 4.45 2 1277],
@dvliman
dvliman / gist:11264471
Created April 24, 2014 18:24
4chan source code leak
<?
if(file_exists('/www/global/lockdown')) {
if($_COOKIE['4chan_auser'] && $_COOKIE['4chan_apass'] && ($_POST['mode']=='usrdel'||$_GET['mode']=='latest')) {
// ok
}
else {
die('Posting temporarily disabled. Come back later!<br/>&mdash;Team 4chan (uptime? what\'s that?)');
}
}
include_once "./yotsuba_config.php";
(ns u.schwab
(:require
[cheshire.core :as json]
[hato.websocket :as ws]
[clj-http.client :as http]
[clojure.string :as str]
[clojure.walk :as walk]
[integrant.core :as ig]
[ring.util.codec :as codec]
[ring.util.response :as response]))
(defn pgobj->clj [^org.postgresql.util.PGobject pgobj]
(let [type (.getType pgobj)
value (.getValue pgobj)]
(case type
"json" (cheshire.core/parse-string value true)
"jsonb" (cheshire.core/parse-string value true)
"citext" (str value)
value)))
(extend-protocol next.jdbc.result-set/ReadableColumn
(defn between [from target to]
(and (<= from target) (<= target to)))
(defn calculate-loan-size
[loan-amount]
(cond
(between 1 loan-amount 10000) :small
(between 10001 loan-amount 50000) :modest
(between 50001 loan-amount 150000) :large
(>= loan-amount 150001) :jumbo))
(defn calculate-loan-size
[loan-amount]
(cond
#d (between 1 loan-amount 10000) :small
#d (between 10001 loan-amount 50000) :modest
#d (between 50001 loan-amount 150000) :large
#d (>= loan-amount 150001) :jumbo))
[{0 [[1 :same-values (between 1 loan-amount 10000)] false]}
{1 [[1 :same-values (between 10001 loan-amount 50000)] false]}
{2 [[1 :same-values (between 50001 loan-amount 150000)] false]}
{3 [[1 :same-values (>= loan-amount 150001)] false]}]
(def log-store (atom {}))
(defn debug [tag val]
(swap! log-store update-in [tag] #(conj (or % []) val))
val)
(defn logs
[tag & functions]
(let [tag (if (number? tag)
(nth (keys @log-store) tag)