Skip to content

Instantly share code, notes, and snippets.

View ph3nx's full-sized avatar

ph3nx ph3nx

View GitHub Profile
@ph3nx
ph3nx / index.html
Created January 30, 2015 12:49
Zeit [add your bin description] // source http://jsbin.com/gazuge
<!DOCTYPE html>
<html></html>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Zeit<style id="jsbin-css">
body {
font: 16px helvetica, arial, sans-serif;
background-color: #eee;
margin: 10px;
}
@ph3nx
ph3nx / cardfan.css
Last active August 29, 2015 13:57
CardFan for TSS website.
body {
background-color: #fff;
font-size: 16px;
font-family: helvetica;
}
.jwlogo {
display: none;
}
@ph3nx
ph3nx / jwplayer.html
Created February 26, 2014 12:13
This is how you setup the jwplayer with a self-hosted video file. The official documentation: http://www.longtailvideo.com/support/jw-player/28833/quick-start-guide
<!-- JW Player Library -->
<script src="http://jwpsrv.com/library/MCK8hplLEeOY0CIACmOLpg.js"></script>
<!-- div for the player -->
<div id='playerKXSDPIwKERSv'></div>
<!-- Script to display video file in the player div -->
<script type='text/javascript'>
jwplayer('playerKXSDPIwKERSv').setup({
// URL to the video file
@ph3nx
ph3nx / app_generator.sh
Created February 8, 2014 19:24
Shell script to generate an rails app with postgres database in osx mavericks.
#!/bin/bash
case "$1" in
"n" )
if [ -z $2 ]
then
echo "Specify an app name"
else
if [ -d ~/rails/$2 ]
then
echo "App '$2' exists already"
@ph3nx
ph3nx / disable_osx_dashboard.sh
Last active August 29, 2015 13:56
Disable Dashboard in osx mavericks.
# Disable Dashboard
defaults write com.apple.dashboard mcx-disabled -boolean true
killall Dashboard
# Enable Dashboard
defaults write com.apple.dashboard mcx-disabled -boolean false
killall Dashboard
@ph3nx
ph3nx / start_chrome.bat
Last active August 29, 2015 13:55
Batchfile to copy updated project files in the webroot and open the website in chrome.
xcopy /s /Y C:\Users\Pascal\drive\Projects\karteikarten C:\xampp\htdocs\karteikarten
chrome "http://localhost/karteikarten"
@ph3nx
ph3nx / round_down_proc.rb
Created January 21, 2014 21:58
Ruby example that explains the usage of Proc's.
floats = [1.2, 3.45, 0.91, 7.727, 11.42, 482.911]
# Write your code below this line!
round_down = Proc.new { |f| f.floor }
# Write your code above this line!
ints = floats.collect(&round_down)
@ph3nx
ph3nx / case.rb
Created January 20, 2014 21:14
Some examples for the case method in Ruby.
case var
when 1
puts 1
when 2
puts 2
else
puts 'none'
end
case var
@ph3nx
ph3nx / benchmark_string_vs_symbol.rb
Created January 20, 2014 19:57
Simple Ruby benchmark to benchmark strings and symbols.
require 'benchmark'
string_AZ = Hash[("a".."z").to_a.zip((1..26).to_a)]
symbol_AZ = Hash[(:a..:z).to_a.zip((1..26).to_a)]
string_time = Benchmark.realtime do
100_000.times { string_AZ["r"] }
end
symbol_time = Benchmark.realtime do
@ph3nx
ph3nx / alphabetize.rb
Last active June 28, 2018 02:26
The Ruby method "alphabetize" sorts an array in alphabetical order. If you wish put true as second argument to sort in descending order.
def alphabetize arr, rev=false
if rev
arr.sort.reverse
else
arr.sort
end
end
puts alphabetize ["b","e","a"], true
# => ["e","b","a"]