Skip to content

Instantly share code, notes, and snippets.

void replace_string_in_place(std::string& subject, const std::string& search,
const std::string& replace) {
size_t pos = 0;
while ((pos = subject.find(search, pos)) != std::string::npos) {
subject.replace(pos, search.length(), replace);
pos += replace.length();
}
}
@rozzy
rozzy / devices-mixins.less
Last active August 29, 2015 14:09
Auto retina images with background-size
@screenMobile: 320px;
@screenTablet: 768px;
@screenDesktop: 992px;
@screenLarge: 1200px;
@screenExtraLarge: 1600px;
.mobile(@rules, @invert: false) {
.mixin (@invert) when (@invert = false) {
@query: ~"(min-width: @{screenMobile})";
@media @query {
@rozzy
rozzy / git-empty-dir.fish
Created July 3, 2014 12:39
Create .gitignore file in empty directories to commit them. (Fish)
function commit-empty-dir -d "Create .gitignore file in empty directories to commit them"
sudo find . -type d -empty -exec touch '{}'/.gitignore \;
end
@rozzy
rozzy / HCKR.terminal
Created July 2, 2014 09:05
install font before: http://goo.gl/6H4xJ
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ANSIBlueColor</key>
<data>
YnBsaXN0MDDUAQIDBAUGFRZYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3AS
AAGGoKMHCA9VJG51bGzTCQoLDA0OVU5TUkdCXE5TQ29sb3JTcGFjZVYkY2xhc3NPECcw
LjIwODQ2NzE3NjIgMC4yMzQ4MDUxMDg3IDAuNjM4OTU3Njc5MwAQAYAC0hAREhNaJGNs
YXNzbmFtZVgkY2xhc3Nlc1dOU0NvbG9yohIUWE5TT2JqZWN0XxAPTlNLZXllZEFyY2hp
@rozzy
rozzy / .bashrc
Created July 2, 2014 08:47
My mac os x .bashrc file
source ~/.ssh_aliases
source ~/.bash_profile
source ~/.functions
source ~/.aliases
@rozzy
rozzy / .vimrc
Created July 2, 2014 08:46
My vim settings
set mousemodel=extend
set ai
set ruler
filetype plugin on
set number
syntax on
set tabstop=2
set shiftwidth=2
set expandtab
@rozzy
rozzy / .aliases.sh
Last active March 19, 2020 03:50
Aliases
alias god=whoami
alias cjpeg="sh ~/cjpeg"
alias lsd="ls -d -- */"
alias subl=sublime
alias deepthroat="cd ~/../../../.."
@rozzy
rozzy / .functions.sh
Last active August 29, 2015 14:02
Made a really useful git auto commit function in Bash. (run w/o .sh extension)
function mkd () {
mkdir -p "$@" && cd "$@"
}
function slow_internet() {
sudo ipfw pipe 1 config bw 128Kbit/s delay 200ms && sudo ipfw add 1 pipe 1 src-port 80
}
function get_file_size () {
ls -lah $@ | awk '{ print $5}'
@rozzy
rozzy / last5articles.php
Created June 22, 2013 12:06
Get 5 last feed articles (html-anchor style)
<?
function getFeed($feed_url) {
$content = file_get_contents($feed_url);
$x = new SimpleXmlElement($content);
$feed = array();
$str = "";
foreach($x->channel->item as $entry) {
if (count($feed) < 5) {
$f = "<li><a href='$entry->link' title='$entry->title'>$entry->title</a></li>";
@rozzy
rozzy / scanimages.php
Created June 21, 2013 12:47
Recursively find all images mentions in all files
<?php
// Run with shell as `php -a scanimages.php`
// If you want to check your actual place, use `pwd`
define(PATH, "/Users/rozzy/Source/Web/mypath/");
$all_files = scandir(PATH);
$may_content = $matches = $end_f = array();
foreach ($all_files as $value) {
$exclude = array(
'.',
'..',