This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
class RingBuffer { | |
public: | |
RingBuffer(int size) : | |
// allocate 1 more element so its easier | |
// to detect if a buffer is full | |
buffer_(size+1), | |
head_(0), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdlib> | |
#include <cstdio> | |
#include <pthread.h> | |
#include <unistd.h> | |
bool running = true; | |
int ITERATION = 10000; | |
struct Node { | |
int value; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import os | |
import time | |
import requests | |
import datetime | |
import pathlib | |
# run fetch | |
dir = str(pathlib.Path(__file__).parent.resolve()) | |
with open(dir + '/urls.json') as rf: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl 'https://www.epicpass.com/api/LiftAccessApi/SubmitPassReservation' \ | |
-H 'authority: www.epicpass.com' \ | |
-H 'accept: application/json, text/javascript, */*; q=0.01' \ | |
-H 'x-queueit-ajaxpageurl: https%3A%2F%2Fwww.epicpass.com%2Fplan-your-trip%2Flift-access%2Freservations.aspx' \ | |
-H 'x-requested-with: XMLHttpRequest' \ | |
-H '__requestverificationtoken: EMzGtuKsgkt6x29YviEYIJtzn2j_VetKM1BZQ03uJ1uu0nGBW1kY3jaWwFzMvFUJ-LFLjd8oJF4Pz5W98sNOYSeNvlo1:7iOZ0ZFGGfI4q80ZB6yCcMlTXdiScqwf3YTZLLmfQzuPOnYscxMM98N0CbIWxs8iQl9EhhO5odOAGuWWl9o4RruUxq1aCJi7kN4CgUhCITxU7E2f0' \ | |
-H 'user-agent: Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Mobile Safari/537.36' \ | |
-H 'content-type: application/json; charset=UTF-8' \ | |
-H 'origin: https://www.epicpass.com' \ | |
-H 'sec-fetch-site: same-origin' \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Tree where | |
import Data.Map | |
import Debug.Trace | |
data Ion = IonSymbol String | IonStruct (Map String Ion) | IonString String | IonList [Ion] deriving Show | |
data Tree a = Node String (Map String (Tree a)) (Maybe (DerivedAttribute Ion)) deriving Show | |
type DerivedAttribute a = Map String a | |
-- TODO | |
-- make derived attribute a new type and add other attribute ctors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class replace { | |
public static void main(String[] args) | |
{ | |
String foo = "{foo}"; | |
System.out.println(foo.replaceAll("\\{foo\\}", "\\\"bar\\\"")); // => \"bar\" | |
System.out.println(foo.replace("{foo}", "\\\"bar\\\"")); // => \\\"bar\\\" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import mysql from 'mysql'; | |
import user from './user'; | |
import post from './post'; | |
class db { | |
constructor() { | |
// init db | |
this.init(); | |
// init connect pool |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void dfs(map<int, vector<int>>& res, | |
vector<pair<int, int>>& cur, | |
vector<pair<int, vector<pair<int, int>>>>& result, | |
int profit, | |
int start) { | |
auto itr = res.lower_bound(start); | |
if (itr == res.end()) { | |
result.emplace_back(profit, cur); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Collections; | |
import java.util.List; | |
import java.util.ArrayList; | |
import java.util.HashSet; | |
public class DependencyGraph | |
{ | |
static int MAX_WR_ID = 1000, | |
MAX_CE_ID = 1000; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <vector> | |
#include <string> | |
using namespace std; | |
// assume all string have same length | |
void radixSort(vector<string>& a, int W) { | |
int R = 256; | |
int N = a.size(); | |
vector<string> aux(N); | |
for (int j = W-1; j >= 0; j--) { |
NewerOlder