Skip to content

Instantly share code, notes, and snippets.

View roelven's full-sized avatar

Roel van der Ven roelven

View GitHub Profile
@roelven
roelven / Get Twitter avatar via JSONP
Created July 21, 2010 07:39
Get Twitter avatar via JSONP client-side
<script type="text/javascript" src="http://code.jquery.com/jquery.js"></script>
<script type="text/javascript">
// Call the Twitter API after blurring the input field where a user entered his Twitter handle
// Get the avatar and append as picture in the HTML
$('#twittername').blur(function() {
console.log('Twitter call');
var tweeter = $('#twittername').val();
$.ajax({
type: 'GET',
processData: true,
@roelven
roelven / Remove ugly stuff in Wordpress headers
Created July 22, 2010 10:32
Remove ugly stuff in Wordpress' wp_head
<?php
//
// Put this in your templates' functions.php for a cleaner header:
//
function remove_x_pingback($headers) {
unset($headers['X-Pingback']);
return $headers;
}
@roelven
roelven / gist:602761
Created September 29, 2010 13:44
DataURIze all images in a dir with PHP
<?php
/*
- Check folder images for available images files (I used gif only in this case)
- Loop through all images and render them inline in HTML, using dataURI's with Base64 encoding through PHP
- View the output in your browser to get the encoded strings
*/
@roelven
roelven / more_clientapplications
Created October 14, 2010 15:30
Create extra ClientApplications on dev environment
# Create extra ClientApplications on dev environment
# Run in script/console
#
# Thanks Johan!
ClientApplication.all.each { |app| AccessToken.create(:user_id => 303477976, :client_application_id => app.id, :authorized_at => Time.now) }
@roelven
roelven / gist:660935
Created November 3, 2010 10:19
Sendmail function with SwiftMailer
function sendMail($subject, $body, $receiver) {
$sender = array('no-reply@inzetkast.nl' => 'Inzetkast.nl');
$transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 465, 'ssl')
->setUsername('post@inzetkast.nl')
->setPassword('xxxx')
;
$mailer = Swift_Mailer::newInstance($transport);
$message = Swift_Message::newInstance($subject)
@roelven
roelven / gist:660977
Created November 3, 2010 11:13
Awesome git functions to check differentiation between branches
##
## Add awesome git functions to check differentiation between branches.
## Add this to your ~/.profile and reload with $ source ~/.profile
##
## See http://stackoverflow.com/questions/53569/how-to-get-the-changes-on-a-branch-in-git
##
function parse_git_branch {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'
}
@roelven
roelven / gist:663124
Created November 4, 2010 20:23
Parse .eml files to retrieve emailaddresses
##
## Parse a whole directory of .eml files
## and retrieve all printed emailaddresses, sort them, and remove duplicates
## and print to a file.
##
perl -wne'while(/[\w\.\-]+@[\w\.\-]+\w+/g){print "$&\n"}' *.* | sort -u > /tmp/output.txt
@roelven
roelven / gist:663332
Created November 4, 2010 22:44
Sort amount of results per city in mysql
SELECT `plaats`, count(*) AS `Number`
FROM `kijkmijnhuis`
GROUP BY `plaats`
ORDER BY `Number` DESC
LIMIT 20;
@roelven
roelven / gist:711818
Created November 23, 2010 14:15
My .profile
##
## My .profile file.
## Replace Roel with your own username!
##
export PS1='\u@\h:\w $(vcprompt)\$ '
export PATH=/usr/local/sbin:$PATH
export CDPATH=/Users/Roel/Sites
##
@roelven
roelven / gist:711865
Created November 23, 2010 14:47
Install rvm
mkdir -p ~/.rvm/src/ && cd ~/.rvm/src && rm -rf ./rvm/ && git clone --depth 1 git://github.com/wayneeseguin/rvm.git && cd rvm && ./install