Skip to content

Instantly share code, notes, and snippets.

View DeaconDesperado's full-sized avatar

Mark Grey DeaconDesperado

  • Spotify
  • NY, New York
View GitHub Profile
@vchernetskyi993
vchernetskyi993 / Cargo.toml
Last active July 2, 2024 04:57
Rust - Single testcontainer for multiple test functions
[package]
name = "testcontainers-sample"
version = "0.1.0"
edition = "2021"
[dev-dependencies]
async_once = "0.2.6"
aws-sdk-s3 = "0.28.0"
ctor = "0.2.4"
lazy_static = "1.4.0"
@insin
insin / app.jsx
Last active July 13, 2021 07:39
React Form Handling - handleFormInputChange (Live version: http://bl.ocks.org/insin/raw/082c0d88f6290a0ea4c7/)
var INPUT_TYPES = 'color|date|datetime|datetime-local|file|month|number|password|range|search|tel|text|time|url|week'.split('|')
var App = React.createClass({
getInitialState: function() {
return {}
},
onChange: handleFormInputChange,
render: function() {
@viktorklang
viktorklang / Future-retry.scala
Last active July 23, 2023 23:48
Asynchronous retry for Future in Scala
import scala.concurrent.duration._
import scala.concurrent.ExecutionContext
import scala.concurrent.Future
import akka.pattern.after
import akka.actor.Scheduler
/**
* Given an operation that produces a T, returns a Future containing the result of T, unless an exception is thrown,
* in which case the operation will be retried after _delay_ time, if there are more possible retries, which is configured through
* the _retries_ parameter. If the operation does not succeed and there is no retries left, the resulting Future will contain the last failure.
@DeaconDesperado
DeaconDesperado / cherrypy_daemon.py
Last active August 12, 2016 23:57
Run cherrypy WSGI server as a daemon
from cherrypy.process.plugins import Daemonizer,PIDFile
import cherrypy
import argparse
parser = argparse.ArgumentParser(description="My server daemon")
parser.add_argument('-d','--daemon',help='Run the server as a daemon using the traditional double fork',action='store_true')
parser.add_argument('-a','--bind-address',help='Network interface to bind to',default='127.0.0.1')
parser.add_argument('-p','--port',help='Port to bind to',default=8080,type=int)
parser.add_argument('--pidfile',help='process id file',type=str)
args = parser.parse_args()
@tyrcho
tyrcho / pca.sc
Last active November 25, 2020 21:37
Principal Component Analysis with Breeze (Scala)
// For an unkown reason, this works when copy/paste in ammonite but not with `amm pca.sc`
import $ivy.`org.scalanlp::breeze-natives:0.13.2`
import $ivy.`org.scalanlp::breeze-viz:0.13.2`
import $ivy.`org.scalanlp::breeze:0.13.2`
import breeze.linalg._
import breeze.linalg.svd._
import breeze.plot._
import scala.util.Random._
@visenger
visenger / install_scala_sbt.sh
Last active January 31, 2023 19:10
Scala and sbt installation on ubuntu 12.04
#!/bin/sh
# one way (older scala version will be installed)
# sudo apt-get install scala
#2nd way
sudo apt-get remove scala-library scala
wget http://www.scala-lang.org/files/archive/scala-2.11.4.deb
sudo dpkg -i scala-2.11.4.deb
sudo apt-get update
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active July 21, 2024 20:54
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@lukaslundgren
lukaslundgren / python27_on_debian.sh
Created May 11, 2012 12:58
How to install python 2.7 on debian
sudo apt-get install build-essential libsqlite3-dev zlib1g-dev libncurses5-dev libgdbm-dev libbz2-dev libreadline5-dev libssl-dev libdb-dev
wget http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz
tar -xzf Python-2.7.3.tgz
cd Python-2.7.3
./configure --prefix=/usr --enable-shared
make
sudo make install
cd ..
from boto.emr.connection import EmrConnection
from boto.emr.step import InstallPigStep, PigStep
AWS_ACCESS_KEY = '' # REQUIRED
AWS_SECRET_KEY = '' # REQUIRED
conn = EmrConnection(AWS_ACCESS_KEY, AWS_SECRET_KEY)
pig_file = 's3://elasticmapreduce/samples/pig-apache/do-reports2.pig'
INPUT = 's3://elasticmapreduce/samples/pig-apache/input/access_log_1'
OUTPUT = '' # REQUIRED, S3 bucket for job output
@mardambey
mardambey / AkkaKafkaMailboxTest.scala
Last active August 3, 2019 05:03
Akka 2.0 actors with Kafka 0.7.x backed durable mailboxes.
import akka.actor.Actor
import akka.actor.ActorSystem
import akka.agent.Agent
import com.typesafe.config.ConfigFactory
import akka.event.Logging
import akka.actor.Props
import kafka.utils.Utils
import java.nio.ByteBuffer