Skip to content

Instantly share code, notes, and snippets.

@songpp
songpp / sort1mb.cpp
Created November 24, 2012 19:01 — forked from preshing/sort1mb.cpp
Sort one million 8-digit numbers in 1MB RAM
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
typedef unsigned int u32;
typedef unsigned long long u64;
//-------------------------------------------------------------------------
// WorkArea
//-------------------------------------------------------------------------
// scala 2.7 simple type constraint. This can only constrain a type parameter of this function.
// Below, in ListW.sumint28, we can't use this approach because we want to constrain T,
// a type param of the enclosing trait.
def sumint27A[T <: Int](l: List[T]) : Int = l.reduceLeft((a: Int, b: Int) => a + b)
trait IntLike[X] extends (X => Int)
object IntLike {
implicit val intIntLike: IntLike[Int] = new IntLike[Int] { def apply(x: Int) = identity(x) }
}
@songpp
songpp / hslint
Created April 5, 2013 16:52 — forked from sritchie/hslint
#!/usr/bin/env perl
# Remember `chmod a+x hslint, after putting on path.
$ghc = '/usr/bin/ghc'; # where is ghc
@ghc_options = ('-Wall'); # e.g. ('-fglasgow-exts')
@ghc_packages = (); # e.g. ('QuickCheck')
### the following should not been edited ###
// requires Scala 2.10.0-M7
def kind[A: scala.reflect.TypeTag]: String = {
import scala.reflect.runtime.universe._
def typeKind(sig: Type): String = sig match {
case PolyType(params, resultType) =>
(params map { p =>
typeKind(p.typeSignature) match {
case "*" => "*"
case s => "(" + s + ")"
}
package com.baidu.cms.thirtpart
import util.parsing.combinator.JavaTokenParsers
import java.io.FileReader
import java.util.regex.Pattern
import com.baidu.cms.thirtpart.TransferRuleContext._
import com.baidu.cms.thirtpart.TransferRuleContext.ActivityRef
import com.baidu.cms.thirtpart.TransferRuleContext.FieldValueFilter
import com.baidu.cms.thirtpart.TransferRuleContext.Rule
import com.baidu.cms.thirtpart.TransferRuleContext.OperatorFetchStrategy
import scala.collection.JavaConversions._
import sbt._
import Keys._
import org.sbtidea._
import SbtIdeaPlugin._
import Scope.{GlobalScope, ThisScope}
object BuildSettings {
val buildOrganization = "com.mojolly.backchat"
val buildScalaVersion = "2.9.0-1"
val buildVersion = "0.8.1-SNAPSHOT"
{
// Sets the colors used within the text area
"color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme",
// Note that the font_face and font_size are overriden in the platform
// specific settings file, for example, "Base File (Linux).sublime-settings".
// Because of this, setting them here will have no effect: you must set them
// in your User File Preferences.
"font_face": "Monaco",
"font_size": 12,
#!/bin/bash
#
# git-svn-diff originally by (http://mojodna.net/2009/02/24/my-work-git-workflow.html)
# modified by mike@mikepearce.net
# modified by aconway@[redacted] - handle diffs that introduce new files
# modified by t.broyer@ltgt.net - fixes diffs that introduce new files
# modified by m@rkj.me - fix sed syntax issue in OS X
# modified by songpengpeng - fix sed newline issue in OS X
#
# Generate an SVN-compatible diff against the tip of the tracking branch
@songpp
songpp / The Technical Interview Cheat Sheet.md
Created June 26, 2016 17:34 — forked from tsiege/The Technical Interview Cheat Sheet.md
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

Studying for a Tech Interview Sucks, so Here's a Cheat Sheet to Help

This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.

Data Structure Basics

###Array ####Definition:

  • Stores data elements based on an sequential, most commonly 0 based, index.
  • Based on tuples from set theory.
@songpp
songpp / introrx.md
Created June 26, 2016 17:40 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing