Skip to content

Instantly share code, notes, and snippets.

@sosukeinu
sosukeinu / Regex:whitespace at end of file
Created January 29, 2013 16:22
Regex:whitespace at end of file
[\s]*$(?![\w\W])
@sosukeinu
sosukeinu / REGEX:inline tag attributes
Last active August 8, 2017 17:32
REGEX:inline tag attributes
class="[^"']+"
style="[^"']+"
etc...
Also: [\s\S]*? match any content BETWEEN two tags (ie. <br>[\s\S]*?</div>)
Can be used like below:
let's say you wanted to comment out all <img> tags
@sosukeinu
sosukeinu / REGEX:empty lines
Created January 29, 2013 16:29
REGEX:empty lines
Use this to find all "wrapping" blank lines. In other words, if you want to delete blank lines in between full lines, use this:
[ \t\n]*$
This one will identify the blank lines, but it will leave empty space between full lines if it is deleted:
^[ \t\n]*$
@sosukeinu
sosukeinu / num-list.py
Created January 29, 2013 16:30
PYTHON comma-separated list of numbers
import sys
lownum = input("Please enter the low number: ")
highnum = input("Please enter the high number: ")
print ', '.join(str(i) for i in range(lownum,highnum + 1))
@sosukeinu
sosukeinu / num-list.sh
Created January 29, 2013 16:32
BASH comma-separated list of numbers
#!/bin/bash
echo "Input variable #1 "
read var1
echo "variable #1 = $var1"
echo
echo "Input variable #2 "
read var2
echo "variable #2 = $var2"
echo
@sosukeinu
sosukeinu / split_join.sh
Created January 29, 2013 17:27
BASH split and join files
##To split files into even-sized, smaller chunks, and combine them back into a single file
##To Split
split -b 100m 'somefile.ext' somefile.
##-b tells the split command that you want to specify the 'byte' size 100m, or 100 megabytes is the size of the parts we wanted 'somefile.ext' is the file we want to split into parts somefile. tells the split command that all part files should begin with 'some file.'
<?php
/**
* An example function used to demonstrate how to use the `user_can_save` function
* that provides boilerplate security checks when saving custom post meta data.
*
* The ultimate goal is provide a simple helper function to be used in themes and
* plugins without the need to use a set of complex conditionals and constants.
*
* Instead, the aim is to have a simplified function that's easy to read and that uses
* WordPress APIs.
<?php
/**
* This little class records how long it takes each WordPress action or filter
* takes to execute which gives a good indicator of what hooks are being slow.
* You can then debug those hooks to see what hooked functions are causing problems.
*
* This class does NOT time the core WordPress code that is being run between hooks.
* You could use similar code to this that doesn't have an end processor to do that.
*

#How I built an audio book reader for my nearly blind grandfather

Tweet this - Follow me

Last year, when visiting my family back home in Holland, I also stopped by my grand-parents. My grand-father, now 93 years old, had always been a very active man. However, during the presceding couple of months, he'd gone almost completely blind and now spent his days sitting in a chair. Trying to think of something for him to do, I suggested he try out audio books. After finally convincing him -- he said audio books were for sad old people -- that listening to a well performed recording is actually a wonderful experience, I realized the problem of this idea.

####The problem with audio devices and the newly blind. After my first impulse to jump up and go buy him an iPod Touch, I soon realized that, to use an iPod, or any audio d

@sosukeinu
sosukeinu / ela.py
Last active August 29, 2015 14:08 — forked from ewencp/ela.py
#!/usr/bin/env python
# This is a really simple implementation of ELA as described in
# http://blackhat.com/presentations/bh-dc-08/Krawetz/Whitepaper/bh-dc-08-krawetz-WP.pdf
# You shouldn't actually use it, or at least read the paper carefully
# and implement more of the techniques before drawing any conclusions.
from PIL import Image, ImageChops, ImageEnhance
import sys, os.path