Skip to content

Instantly share code, notes, and snippets.

@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 / 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(
'.',
'..',
@rozzy
rozzy / CoffeeScript.build-system.js
Last active December 10, 2015 15:38
Final version my coffee-build-system in Sublime Text 2. Coffee-files will compile into the parent directory. It's very useful, i think.
{
"cmd": ["coffee", "--compile", "--output", "../", "$file_name"],
"path": "/usr/local/bin:$PATH",
"selector": "source.coffee",
"working_dir": "$file_path"
}
@rozzy
rozzy / Sass & Slim.sublime-build.js
Last active December 10, 2015 15:08
Compile Sass & Slim via this sublime build. Put into `Sublime Text 2/packages/user/`
{
"cmd": ["if [ \"$file_extension\" = \"sass\" ]; then sass --watch $file_name:../${file_base_name}.css --style compressed; elif [ \"$file_extension\" = \"slim\" ]; then slimrb -p $file_name ../$file_base_name.html; fi"],
"selector": "source.slim,source.sass",
"working_dir": "$file_path",
"path": "/usr/local/bin:$PATH",
"shell": true
}
function getCaret(node) {
if (node.selectionStart) {
return node.selectionStart;
} else if (!document.selection) {
return 0;
}
var c = "\001",
sel = document.selection.createRange(),
dul = sel.duplicate(),
len = 0;
@rozzy
rozzy / lastfm_events.rb
Created September 9, 2012 13:45 — forked from makaroni4/lastfm_events.rb
Get all the events in location from last.fom
#ruby
require "rubygems"
require "net/http"
require 'nokogiri'
#API
PARAMS = %w(title website description)
API_KEY = "YOUR KEY"
LOCATION = "moscow"
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