Skip to content

Instantly share code, notes, and snippets.

@wcharczuk
wcharczuk / queens.scala
Created February 27, 2014 15:11
Solution to the 8 Queens Problem in Scala
class Board() {
val min_rank = 0
var max_rank = 8
val min_file = 0
var max_file = 8
var data : Array[Array[Square]] = null
def initialize(ranks : Int, files: Int) = {
@wcharczuk
wcharczuk / gist:d65364edeb57853bd55d
Created May 20, 2014 14:40
Postgres toy example of in statement
CREATE TABLE id_test ( id varchar(255) not null );
ALTER TABLE id_Test ADD CONSTRAINT PK_id_test_id PRIMARY KEY (id);
INSERT INTO id_test
select uuid_generate_v1() as id from generate_series(1,10000);
select '''' || id || ''',' from id_test limit 100
--these values go in the 'in' statement below
select * from id_test where id in (
# Put any initialization logic here. The context object will be passed to
# the other methods in your algorithm.
def initialize(context):
context.security = symbol('SPY')
context.date = None
context.buy_amt = 1000
set_commission(commission.PerTrade(cost=0.03))
set_slippage(slippage.VolumeShareSlippage(volume_limit=0.25, price_impact=0.1))
#!/usr/bin/python
import sys
keyboard = []
keyboard.append(['A', 'B', 'C', 'D', 'E', 'F'])
keyboard.append(['G', 'H', 'I', 'J', 'K', 'L'])
keyboard.append(['M', 'N', 'O', 'P', 'Q', 'R'])
keyboard.append(['S', 'T', 'U', 'V', 'W', 'X'])
keyboard.append(['Y', 'Z', '1', '2', '3', '4'])
@wcharczuk
wcharczuk / keybase.md
Created May 26, 2015 20:41
keybase.md

Keybase proof

I hereby claim:

  • I am wcharczuk on github.
  • I am wcharczuk (https://keybase.io/wcharczuk) on keybase.
  • I have a public key whose fingerprint is 0709 214A D115 6D81 F954 279D 60B0 4013 AFE9 F2B1

To claim this, I am signing this object:

@wcharczuk
wcharczuk / sudoku-hard.txt
Created August 31, 2015 18:01
Hard sudoku board
5 3 _ _ 8 _ _ _ 2
7 _ _ 6 _ _ 3 _ _
_ _ 2 3 _ _ 1 _ _
_ _ _ _ _ _ _ _ 3
_ 7 _ 2 _ 5 _ 6 _
1 _ _ _ _ _ _ _ _
_ _ 5 _ _ 7 2 _ _
_ _ 9 _ _ 6 _ _ 7
6 _ _ _ 3 _ _ 9 5
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BalancedParens
{
class Program
{
@wcharczuk
wcharczuk / StreamExtensions.cs
Created August 17, 2011 19:13
Stream Extensions
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
namespace yourNameSpaceHere
{
public static class StreamExtensions
{
@wcharczuk
wcharczuk / gist:1353509
Created November 9, 2011 23:19
C# Exception performance hit example
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ExceptionsAreBad
{
class Program
{
@wcharczuk
wcharczuk / iclean.py
Created November 18, 2011 19:08
iTunes Media Directory Extra Files Cleaner
from pyItunes import *
import os
import sys
import urllib
extraFiles = []
libraryLocation = None
if len(sys.argv) > 1:
libraryLocation = sys.argv[1]
else: