Skip to content

Instantly share code, notes, and snippets.

View fearofcode's full-sized avatar
🎵
Take that chance / All day long / Fucking up so fucking strong

Warren Henning fearofcode

🎵
Take that chance / All day long / Fucking up so fucking strong
View GitHub Profile
@fearofcode
fearofcode / MainWindow.xaml
Created September 4, 2018 08:52
simple .NET WPF BackgroundWorker test where long running task reports text back and it scrolls into a textbox that won't get messed up when you click/select it. the textbox scrolls to the end as lines come in.
<Window x:Class="databinding.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:databinding"
mc:Ignorable="d"
Title="MainWindow"
Height="450"
Width="400">
@fearofcode
fearofcode / wordcounter.cs
Last active September 2, 2018 23:06
simple C# concurrent word counter based on https://www.youtube.com/watch?v=B5xYBrxVSiE
using System;
using System.IO;
using System.Linq;
using System.Diagnostics;
using System.Collections.Concurrent;
namespace wordcounter
{
class Program
{
@fearofcode
fearofcode / dynamiccompilation.cs
Created September 1, 2018 07:59
Simple working example of dynamically compiling a string of valid C# code and calling it
using System;
using System.CodeDom.Compiler;
using Microsoft.CSharp;
using System.Reflection;
namespace dynamiccompilation
{
class Program
{
@fearofcode
fearofcode / npgsql_example.cs
Created August 30, 2018 07:38
Simple working example of working with Npgsql.
using System;
using Npgsql;
namespace learningcsharp
{
class Program
{
static void Main(string[] args)
{
var connString = "Host=localhost;Username=arete;Database=arete";
@fearofcode
fearofcode / evaluator_server.py
Last active August 26, 2018 11:07
Evaluate a Python file and pipe it to stdout in a hot reload loop
import sys
import io
import traceback
import socketserver
class EvaluationHandler(socketserver.BaseRequestHandler):
def handle(self):
while True:
path = self.request.recv(2048).strip()
# http://stackoverflow.com/a/1667114
# https://kristerw.blogspot.com/2017/09/useful-gcc-warning-options-not-enabled.html
# various other places
CFLAGS = -Wall -Wextra -Wshadow -Werror -Wfatal-errors -pedantic -std=gnu11 -m64 \
-Wno-missing-braces -Wno-missing-field-initializers -Wformat=2 \
-Wswitch-default -Wswitch-enum -Wcast-align -Wpointer-arith \
-Wbad-function-cast -Wstrict-overflow=5 -Wstrict-prototypes -Winline \
-Wundef -Wnested-externs -Wcast-qual -Wshadow -Wunreachable-code \
-Wlogical-op -Wfloat-equal -Wstrict-aliasing=2 -Wredundant-decls \
-Wold-style-definition -Wduplicated-cond -Wduplicated-branches -Wrestrict \
https://www.digitalocean.com/community/tutorials/initial-server-setup-with-ubuntu-16-04
disable root login: https://askubuntu.com/questions/27559/how-do-i-disable-remote-ssh-login-as-root-from-a-server
setup remote postgres login (yes, I used a strong, randomly generated password):
https://www.digitalocean.com/community/tutorials/ufw-essentials-common-firewall-rules-and-commands
https://bosnadev.com/2015/12/15/allow-remote-connections-postgresql-database-server/
@fearofcode
fearofcode / new_machine_setup.txt
Last active July 29, 2018 20:51
commands run to get a new ubuntu installation working how I want
# download chrome manually
# java (using default-jdk gave SSL errors with gradle https://askubuntu.com/questions/971059/17-10-openjdk-and-oracle-jdk-8-and-9-the-trustanchors-parameter-must-be-non-empt)
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
# download and install intellij manually
# fonts
@fearofcode
fearofcode / WhatCouldGoWrong.java
Created January 27, 2018 21:39
Type erasure example
class WhatCouldGoWrong<T, U> {
T t;
U u;
public void set(T t) {
this.t = t;
}
public void set(U u) {
this.u = u;
@fearofcode
fearofcode / gist:5f07ac8fba86c33767ea17ff05e54f7a
Last active December 23, 2017 21:20
postgres loading example
example output from running scripts in https://github.com/fearofcode/nyc-taxi-data follows.
base script, 2tb HDD, vanilla postgres settings fresh from ubuntu install. 4 CPUs, 8 GB VM RAM. ubuntu 16.04, postgres 10.
sedding a 14 million line CSV and then COPYing it in:
Thu Dec 21 23:30:18 PST 2017: beginning load for data/yellow_tripdata_2009-01.csv
COPY 14092413
Thu Dec 21 23:34:57 PST 2017: finished raw load for data/yellow_tripdata_2009-01.csv