Skip to content

Instantly share code, notes, and snippets.

View node.ts
import { log, Config, ConfigImpl, EnvSetup, EventBus, Message } from "./services/config";
import { Server, Socket } from "socket.io";
import http from "http";
import handler from "serve-handler";
import devices from "./services/device";
import path from "path";
import serialize from "serialize-javascript";
export class SocketMessage implements Message {
constructor(public server: Server) {}
View backup.md

Today 2021-03-02: I tried using restic to generate backups (perhaps frequently) on my Ubuntu 20.04 laptop. I used a command like that below.

# install
brew install restic

# initialize the repo
restic init -r Backup/home

# perform a backup; I did this a few times for testing
View matt.py
columns = [["apples", "oranges", "pears", "eggplant"],
["red", "blue", "green"],
["joey", "matt", "david", "someone else"]]
columns = {"fruit": ["apples", "oranges", "pears", "eggplant"],
"colors": ["red", "blue", "green", "purple"],
"names": ["joey", "matt", "david", "someone else"]}
widths = [
max([len(entry) for entry in column])
View linux_setup.md
- X windows key
- X GPG
- X ssh keys
- X AWS credentialsls


Folders:

- X Downloads
@drasch
drasch / lenovo.txt
Last active Feb 6, 2018
boxstarter
View lenovo.txt
# Description: Boxstarter Script
# Author: Jess Frazelle <jess@linux.com>
# Last Updated: 2017-09-11
#
# Install boxstarter:
# . { iwr -useb http://boxstarter.org/bootstrapper.ps1 } | iex; get-boxstarter -Force
#
# You might need to set: Set-ExecutionPolicy RemoteSigned
#
# Run this boxstarter by calling the following from an **elevated** command-prompt:
View keybase.md

Keybase proof

I hereby claim:

  • I am drasch on github.
  • I am drasch (https://keybase.io/drasch) on keybase.
  • I have a public key whose fingerprint is 175C 04DA 392D 2401 1EAA 6D1E 6F84 0576 ECB3 D1C7

To claim this, I am signing this object:

View hdf5_python_octave.md

Octave to Python

Octave

octave:1> a = rand(10,10)
a =

  0.859429   0.895490   0.366489   0.209172   0.115529   0.212583   0.346897   0.737492   0.520998   0.765509
  0.458690   0.832058   0.600122   0.703332   0.339640   0.579577   0.330600   0.228996   0.669966   0.292111
  0.690453   0.306055   0.040796   0.379313   0.295865   0.064997   0.925082   0.709484   0.145930   0.787097
  0.995525   0.717836   0.641777   0.189449   0.610176   0.976574   0.316809   0.709783   0.588515   0.694197
View data_frame.py
df = pd.DataFrame(np.random.randn(10000), index=range(0,10000), columns=['length'])
df.index.name = 'id'
df2 = pd.DataFrame.from_dict({'selector':randint(0,2, 20000), 'df_index': randint(1,10000,20000)})
# df_index is a foreign key into df.index
df['in_selector_0'] = np.asarray(np.where(df.reset_index().id.isin(df2[df2.selector.between(0,0.1)].df_index),'y', 'n'))
df.in_selector_0.value_counts()
@drasch
drasch / results.txt
Last active Dec 11, 2015
testing ruby vs php function call performance
View results.txt
## Ruby
$ ruby test.rb #1.8.7
Timing ruby_no_func - 11.53991
Timing ruby_func - 24.726644
real 0m37.154s
$ ruby test.rb #1.9.3
Timing ruby_no_func - 5.672002329
Timing ruby_func - 10.549024467
View fix_sql_injection.rb
# Monkey patch for CVE-2012-2695 on Rails 2.3.14
# put this file in your config/initializers directory
# comments/corrections: https://gist.github.com/2921706
#
# minor modification for rails 2.2 by DCR
# Ruby on Rails SQL Injection
# based on a patch from @presidentbeef
# https://rubyonrails-security.googlegroups.com/attach/aee3413fb038bf56/2-3-sql-injection.patch?view=1&part=3