Skip to content

Instantly share code, notes, and snippets.

@sooop
sooop / StreamReader.swift
Last active May 28, 2023 13:00
Read a large text file line by line - Swift 3
import Foundation
class StreamReader {
let encoding: String.Encoding
let chunkSize: Int
let fileHandle: FileHandle
var buffer: Data
let delimPattern : Data
var isAtEOF: Bool = false
@lsd
lsd / IdeaVim OS X Key Repeat.markdown
Last active December 12, 2023 18:09
Enable key-repeat for ALL applications or just for IdeaVim/specific JetBrains apps

Upgrading to Lion or Yosemite and WebStorm 9, I noticed key repeat was
turned off for the IdeaVim plugin h j k l keys.

System-wide key repeat

defaults write -g ApplePressAndHoldEnabled -bool false in a terminal will enable
key repeat for every app. This can alternatively be found in the accessibility settings in OS X' preferences.

App specific key repeat

@neilpa
neilpa / CStringArray.swift
Last active August 7, 2020 02:24
Swift wrappers for C functions taking char** arguments
// Usage
let argv = CStringArray(["ls", "/"])
posix_spawnp(nil, argv.pointers[0], nil, nil, argv.pointers, nil)
// Is this really the best way to extend the lifetime of C-style strings? The lifetime
// of those passed to the String.withCString closure are only guaranteed valid during
// that call. Tried cheating this by returning the same C string from the closure but it
// gets dealloc'd almost immediately after the closure returns. This isn't terrible when
// dealing with a small number of constant C strings since you can nest closures. But
@mlanett
mlanett / rails http status codes
Last active April 13, 2024 13:40
HTTP status code symbols for Rails
HTTP status code symbols for Rails
Thanks to Cody Fauser for this list of HTTP responce codes and their Ruby on Rails symbol mappings.
Status Code Symbol
1xx Informational
100 :continue
101 :switching_protocols
102 :processing
@stansidel
stansidel / activate_swap.sh
Last active August 29, 2015 13:56
Activate swap file on Ubuntu (based on the tutorial for DigitalOcean - https://www.digitalocean.com/community/articles/how-to-add-swap-on-ubuntu-12-04)
sudo dd if=/dev/zero of=/swapfile bs=1024 count=1024k
sudo mkswap /swapfile
sudo swapon /swapfile
echo "/swapfile none swap sw 0 0 " | sudo tee -a /etc/fstab
echo 0 | sudo tee /proc/sys/vm/swappiness
echo vm.swappiness = 0 | sudo tee -a /etc/sysctl.conf
sudo chown root:root /swapfile
sudo chmod 0600 /swapfile
swapon -s
@lodestone
lodestone / install-macvim-with-lua.sh
Created January 25, 2014 09:17
brew install macvim with lua
brew install macvim --with-cscope --with-lua --override-system-vim
@seyDoggy
seyDoggy / config for vim 7.4 with lua on ubuntu 13.04
Last active December 24, 2015 05:09
I was having trouble getting lua support while rolling my own vim 7.4 on ubuntu 13.04.
sudo apt-get install liblua5.1-dev
sudo mkdir /usr/include/lua5.1/include/
sudo cp /usr/include/lua5.1/* /usr/include/lua5.1/include/
sudo ln -s /usr/lib/x86_64-linux-gnu/liblua5.1.so /usr/local/lib/liblua.so
hg clone https://code.google.com/p/vim/
cd vim
./configure --with-features=huge \
--enable-perlinterp \
--enable-rubyinterp \
--enable-pythoninterp=yes \
@ronanguilloux
ronanguilloux / script-bash-redmine-backups
Last active September 17, 2021 06:32 — forked from gabrielkfr/script-bash-redmine-backups
Backup script (daily & monthly) for Redmine (full instance + db sql snapshot)
#! /bin/bash
#
# backup_redmine.sh
# modified by ronan@lespolypodes.com
# Inspiration: https://gist.github.com/gabrielkfr/6432185
#
# Distributed under terms of the MIT license.
# -- VARS
DAY=`date +"%Y%m%d"`
@bradmontgomery
bradmontgomery / install-comodo-ssl-cert-for-nginx.rst
Last active April 1, 2024 11:21
Steps to install a Comodo PositiveSSL certificate with Nginx.

Setting up a SSL Cert from Comodo

I use Namecheap.com as a registrar, and they resale SSL Certs from a number of other companies, including Comodo.

These are the steps I went through to set up an SSL cert.

Purchase the cert

@aras-p
aras-p / preprocessor_fun.h
Last active April 12, 2024 17:24
Things to commit just before leaving your job
// Just before switching jobs:
// Add one of these.
// Preferably into the same commit where you do a large merge.
//
// This started as a tweet with a joke of "C++ pro-tip: #define private public",
// and then it quickly escalated into more and more evil suggestions.
// I've tried to capture interesting suggestions here.
//
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant,