Skip to content

Instantly share code, notes, and snippets.

@bojanbjelic
bojanbjelic / RecursiveReplace.ps
Created January 16, 2012 12:33 — forked from jongalloway/RecursiveReplace.ps
Recursive replace in files (PowerShell)
$find = 'jquery-1\.4\.4'
$replace = 'jquery-1\.5\.1'
$match = '*.cshtml' , '*.vbhtml'
$preview = $true
foreach ($sc in dir -recurse -include $match | where { test-path $_.fullname -pathtype leaf} ) {
select-string -path $sc -pattern $find
if (!$preview) {
(get-content $sc) | foreach-object { $_ -replace $find, $replace } | set-content $sc
}
@bojanbjelic
bojanbjelic / xml2json.xsl
Created January 18, 2012 11:24
XML to JSON
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" encoding="utf-8"/>
<xsl:template match="/node()">
<xsl:text>{</xsl:text>
<xsl:apply-templates select="." mode="detect" />
<xsl:text>}</xsl:text>
</xsl:template>
@bojanbjelic
bojanbjelic / stat.bash
Created March 6, 2012 23:29
List files with permissions
stat -f '%A %a %N' *
@bojanbjelic
bojanbjelic / alfred-script.sh
Created April 11, 2012 08:10 — forked from gka/alfred-script.sh
Local full-text search on tweets and favorites
cd /your/local/path/to/tweet-search/
rm last-results.html
search.py {query}
open last-results.html
@bojanbjelic
bojanbjelic / .htaccess
Created April 20, 2012 21:31 — forked from necolas/.htaccess
Simple, quick way to concatenate, minify, and version static files in a Wordpress theme
# Filename-based cache busting
# taken from https://github.com/h5bp/html5-boilerplate/
# This rewrites file names of the form `name.123456.js` to `name.js`
# so that the browser doesn't use the cached version when you have
# updated (but not manually renamed) the file.
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
@bojanbjelic
bojanbjelic / uri.js
Created April 24, 2012 09:33 — forked from jlong/uri.js
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@bojanbjelic
bojanbjelic / edit-hosts
Created May 13, 2012 17:03
edit hosts file on mac osx
sudo nano /private/etc/hosts
dscacheutil -flushcache
@bojanbjelic
bojanbjelic / add_slug_to_body_class.php
Created May 21, 2012 15:17 — forked from keirwhitaker/add_slug_to_body_class.php
WordPress Page Template Snag Lists
<?php
// Add the filter and function to your functions.php file
add_filter('body_class', 'add_slug_to_body_class');
function add_slug_to_body_class($classes) {
global $post;
if(is_page()) {
$classes[] = sanitize_html_class($post->post_name);
};
@bojanbjelic
bojanbjelic / wget.bash
Created May 21, 2012 21:12
Site link list
wget --force-html -r -l2 http://www.bjelic.net 2>&1 | grep '^--' | grep -v '\.\(txt\|ico\|css\|js\|png\|gif\|jpg\)$' > linklist.txt
@bojanbjelic
bojanbjelic / gist:2896108
Last active October 5, 2015 23:37
wget test site
wget --no-cache --spider -r -l 2 http://localhost/gvsi/ -o scan.log