Skip to content

Instantly share code, notes, and snippets.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <netinet/tcp.h>
int main(int argc, const char *argv[])
{
@lpiepiora
lpiepiora / Mac OS X 10_5_ Windows Ctrl.xml
Created May 1, 2020 07:16 — forked from fljot/Mac OS X 10_5_ Windows Ctrl.xml
AutoHotkey mappings to emulate OSX keyboard shortcuts on Windows
<!-- put this to IDEA keymaps config folder. For v13 it is <userdir>\.IntelliJIdea13\config\keymaps\ -->
<?xml version="1.0" encoding="UTF-8"?>
<keymap version="1" name="Mac OS X 10.5+ Windows Ctrl" parent="Mac OS X 10.5+">
<action id="$Copy">
<keyboard-shortcut first-keystroke="meta C" />
<keyboard-shortcut first-keystroke="meta INSERT" />
<keyboard-shortcut first-keystroke="control C" />
<keyboard-shortcut first-keystroke="control INSERT" />
</action>
<action id="$Cut">
@lpiepiora
lpiepiora / .zshrc
Created January 14, 2017 08:51
ZSH configuration
# load zgen
source "${HOME}/.zgen/zgen.zsh"
# if the init scipt doesn't exist
if ! zgen saved; then
echo "Creating a zgen save"
# prezto and modules
zgen prezto
import java.io.PrintStream
def log(m: String)
(implicit o: PrintStream,
prefix: String): Unit = o.println(s"[$prefix] $m")
implicit val out: PrintStream = System.out
def ?[T](implicit w: T): T = w
@lpiepiora
lpiepiora / Bash Prompt
Last active August 29, 2015 14:13
Coloured bash prompt with git support
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\[\033[0;33m\]$(__git_ps1 "[%s]")\[\e[0m\]\$ '
\[\033[01;32m\]\u@\h\[\033[0;33m\]$(parse_git_branch)\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$

Getting Started with NPM (as a developer)

If you haven't already set your NPM author info, now you should:

npm set init.author.name "Your Name"
npm set init.author.email "you@example.com"
npm set init.author.url "http://yourblog.com"

npm adduser

@lpiepiora
lpiepiora / idea64.vmoptions
Created September 21, 2014 16:57
IDEA Options
-Xms128m
-Xmx750m
-XX:MaxPermSize=350m
-XX:ReservedCodeCacheSize=96m
-ea
-Dsun.io.useCanonCaches=false
-Djava.net.preferIPv4Stack=true
-Djsse.enableSNIExtension=false
-XX:+UseCodeCacheFlushing
-XX:+UseConcMarkSweepGC
@lpiepiora
lpiepiora / gist:80593e34c547186a7ebb
Last active August 29, 2015 14:02
scalania18.scala
def mostCommon(l: ParSeq[Int]): Int = {
def map(acc: Map[Int, Int], el: Int) = acc.updated(el, acc.getOrElse(el, 0) + 1)
def reduce(accA: Map[Int, Int], accB: Map[Int, Int]) = accA ++ accB.map { case (k, v) => k -> (v + accA.getOrElse(k, 0)) }
l.aggregate(Map[Int, Int]())(map, reduce).maxBy(_._2)._1
}
List of 1000000 elements
Sequential time: 923 milliseconds
@lpiepiora
lpiepiora / gist:6824037
Last active December 24, 2015 15:58
Display git branch in a shell
# See unpushed commits
# git log --branches --not --remotes --simplify-by-decoration --decorate --oneline
# Comment in the above and uncomment this below for a color prompt
function parse_git_branch {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
echo "["${ref#refs/heads/}"]"
}
GREEN="\[\033[01;32m\]"