Skip to content

Instantly share code, notes, and snippets.

@lionelyoung
lionelyoung / gist:755145
Created December 26, 2010 01:48
Connecting to PDANet WiFi HotSpot with Linux
ifconfig wlan0 down
iwconfig wlan0 mode ad-hoc
iwconfig wlan0 essid <ESSID>
iwconfig wlan0 key <TENDIGITPASSWORD>
ifconfig wlan0 up
dhclient wlan0
@lionelyoung
lionelyoung / http_server_auth.py
Last active September 4, 2022 15:07 — forked from mauler/http_server_auth.py
Python3 http.server supporting basic HTTP Auth (username/password)
# Extended python -m http.serve with --username and --password parameters for
# basic auth, based on https://gist.github.com/fxsjy/5465353
# Usage: python -m http_server_auth -u USERNAME -p PASSWORD -d .
from functools import partial
from http.server import SimpleHTTPRequestHandler, test
import base64
import os
class AuthHTTPRequestHandler(SimpleHTTPRequestHandler):
import React from "react"
import Head from "next/head"
import { ApolloProvider } from "@apollo/react-hooks"
import { ApolloClient } from "apollo-client"
import { InMemoryCache } from "apollo-cache-inmemory"
import { HttpLink } from "apollo-link-http"
import fetch from "isomorphic-unfetch"
let apolloClient = null
#!/usr/bin/env bash
# Download ta-lib-0.4.0-src.tar.gz and:
if [[ ! -f "ta-lib-0.4.0-src.tar.gz" ]]; then
wget http://prdownloads.sourceforge.net/ta-lib/ta-lib-0.4.0-src.tar.gz
fi
# untar and cd
if [[ ! -d "ta-lib" ]]; then
tar xvf ta-lib-0.4.0-src.tar.gz
fi
@lionelyoung
lionelyoung / rss_blogspot_to_org.py
Created March 28, 2020 05:35
Download xml and parse it into org mode for reading. Requires the full content to be in the RSS feed
#!/usr/bin/env python
# Download xml and parse it into org mode for reading
# Requires the full content to be in the RSS feed
import argparse
from lxml import etree
import logging
import os
import requests
import subprocess
import sys
@lionelyoung
lionelyoung / labeling_plus.py
Last active January 21, 2020 13:32
update mlfinlab.labeling to use indexes profit taking and stop loss horizontal barriers
def apply_pt_sl_on_t1(close, events, pt_sl, molecule): # pragma: no cover
"""
Snippet 3.2, page 45, Triple Barrier Labeling Method
This function applies the triple-barrier labeling method. It works on a set of
datetime index values (molecule). This allows the program to parallelize the processing.
Mainly it returns a DataFrame of timestamps regarding the time when the first barriers were reached.
:param close: (series) close prices
#!/usr/bin/env bash
# https://lightgbm.readthedocs.io/en/latest/Installation-Guide.html#macos
# Mac Mojave, using Apple Clang
set -e
info () {
printf " [ \033[00;34m..\033[0m ] $1\n"
}
from qtpylib.algo import Algo
from qtpylib import futures
class DebugPosition(Algo):
def on_start(self):
self.counter = 0
self.counter_at_entry = 0
def on_fill(self, instrument, order):
@lionelyoung
lionelyoung / easylanguage-mode.obj
Created December 6, 2017 15:41
easylanguage-mode
;; easylanguage mode
;; https://www.emacswiki.org/emacs/GenericMode
;; too many members for the default specpdlsize
;; still missing some options, processed via
;; #!/bin/sh
;; cat $1 | awk '{ print $1 }' | tr -d ";" | grep = | cut -f1 -d= | sort -u | while read x; do echo -n "\"$x\" "; done
(setq max-specpdl-size 6000)
(define-generic-mode 'easylanguage-mode
;; comments
@lionelyoung
lionelyoung / finddir.sh
Created July 9, 2017 02:49
Find a subdirectory name with maxdepth
# Find dir
# https://stackoverflow.com/questions/2824504/how-do-i-prevent-find-from-printing-git-folders
function finddir () {
# Defaults
DEPTH=4
# Arg check
if [ "$#" -gt 2 ] || [ "$#" -lt 1 ] ; then
echo "Illegal number of parameters"
fi