Skip to content

Instantly share code, notes, and snippets.

View onelson's full-sized avatar
🏠
Working from home

Owen Nelson onelson

🏠
Working from home
View GitHub Profile
@simpixelated
simpixelated / build-non-split.js
Last active March 9, 2021 11:26
Disable Code Splitting (and caching) In Create React App
const rewire = require('rewire');
const defaults = rewire('react-scripts/scripts/build.js');
let config = defaults.__get__('config');
config.optimization.splitChunks = {
cacheGroups: {
default: false,
},
};
anonymous
anonymous / playground.rs
Created July 12, 2017 19:34
Rust code shared from the playground
use std::cell::RefCell;
struct Foo<'a> {
items: Vec<u8>,
cur_item: RefCell<Option<&'a u8>>
}
impl<'a> Foo<'a> {
fn mutate(&mut self) {}
}
@jhass
jhass / README.md
Last active May 7, 2024 07:11 — forked from yorkxin/README.md
Proxy to remote server with CORS support

cors.py for mitmproxy

Hacking CORS restriction to enable in-browser XHR to any server.

Usage

Say you are running an web app at localhost, and you want to send XHR to http://remote-server:80, but the CORS restriction forbids access because you are sending requests from an origin that remote-server:80 does not allow.

Run:

@Apsu
Apsu / change.py
Created June 9, 2016 19:58
SICP Python Conversion
#!/usr/bin/env python
def count_change(amount):
return cc(amount, 5)
def cc(amount, kinds_of_coins):
if(amount == 0):
return 1
@wolever
wolever / shim.js
Last active November 5, 2015 21:39
My Webpack config
// Used to define the asset prefix at runtime
__webpack_require__.p = window.WEBPACK_ASSET_PREFIX || "ERROR-WEBPACK_ASSET_PREFIX-NOT-SET/";
@shreyaskarnik
shreyaskarnik / Instructions.md
Last active March 24, 2023 15:35
Route Docker Logs to ELK Stack
  • With Docker 1.8.0 shipped new log-driver for GELF via UDP, this means that the logs from Docker Container(s) can be shipped directly to the ELK stack for further analysis.
  • This tutorial will illustrate how to use the GELF log-driver with Docker engine.
  • Step 1: Setup ELK Stack:
    • docker run -d --name es elasticsearch
    • docker run -d --name logstash --link es:elasticsearch logstash -v /tmp/logstash.conf:/config-dir/logstash.conf logstash logstash -f /config-dir/logstash.conf
    • Note the config for Logstash can be found at this link
    • docker run --link es:elasticsearch -d kibana
  • Once the ELK stack is up now let's fire up our nginx container which ships its logs to ELK stack.
  • LOGSTASH_ADDRESS=$(docker inspect --format '{{ .NetworkSettings.IPAddress }}' logstash)
  • `docker run -d --net=host --log-driver=gelf --log-opt gelf-address=u
@mucaho
mucaho / src.YOUR_CODE.scala
Created February 13, 2014 10:42
Akka Actors to be executed in Swing / JavaFX thread - based on Victor Klang's [Swing Actors](https://gist.github.com/viktorklang/2422443)
// After that we just create the GUI Actors with a Props with the correct dispatcher set:
val javaFxActor = context.actorOf(Props[JavaFxActor].withDispatcher("javafx-dispatcher"), "javaFxActor")
val swingActor = context.actorOf(Props[SwingActor].withDispatcher("swing-dispatcher"), "swingActor")
// Done! Now all messages processed by the new actor will be executed by the Swing/JavaFX Event Dispatch Thread, enjoy!
@metamorph
metamorph / gist:5003153
Created February 21, 2013 08:21
Tiny embryo for an IRC bot using Akka I/O
import akka.actor.ActorSystem
import akka.io.IO
import akka.io._
object Boot extends App {
import akka.io.Tcp._
implicit val sys = ActorSystem("io")
import akka.actor.{Actor, Props, ActorRef}
@cgallemore
cgallemore / ramdisk.bash
Created August 20, 2012 12:26
Script to setup MySQL on ramdisk after restart
#!/bin/bash
# This is a script I use to setup MySQL on ramdisk
# after I need to reboot. This assumes that you already
# have MySQL installed and have previously moved your
# MySQL files to a backup location, e.g.:
# mv /var/lib/mysql /home/cgallemore/workspace/mysql
stop mysql