Skip to content

Instantly share code, notes, and snippets.

View ph3nx's full-sized avatar

ph3nx ph3nx

View GitHub Profile
@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 / 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 / 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 / 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 / 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 / rails_request_headers.erb
Last active January 3, 2016 04:19
Two code examples on how to display all request headers in Ruby on Rails.
<% request.header do |k, v| %>
"<%= k %>" => <%= v %><br>
<% end %>
<% for header in request.env.select {|k,v| k.match("^HTTP.*")} %>
"<%=header[0].split('_',2)[1]%>" => <%=header[1]%><br>
<% end %>
@ph3nx
ph3nx / square_numbers.java
Created January 14, 2014 12:14
Die Methode quadratzahlen(int n) erzeugt Anzahl n Quadratzahlen und gibt diese addiert, sowie deren Durchschnitt aus.
public class Arrays {
public static void main(String[] args) {
int[] numbers = new int[5];
numbers[0] = 5;
int l = numbers.length;
@ph3nx
ph3nx / Dice.java
Last active January 3, 2016 05:39
Die Klasse Dice stellt einen Würfel dar. Bei der Erzeugung eines Objekts wird die Anzahl an Würfen eingegeben, die durchgeführt werden sollen. Mit Hilfe der Methode zeigeStatistik() erhält man eine Übersicht wie oft jede Zahl gewürfelt wurde sowie den Durchschnitt, der normal wäre.
public class Dice {
private int anzahl;
private int grenze = 6;
private int[] zaehler = new int[6];
Dice(int wuerfeAnzahl){
anzahl = wuerfeAnzahl;
@ph3nx
ph3nx / rand_str.rb
Created January 17, 2014 12:40
Generate random strings in Ruby. You can use this method for instance to generate random subdomains.
def rand_str length
('a'..'z').to_a.shuffle[0..length].join
end
@ph3nx
ph3nx / sum_to.rb
Last active January 3, 2016 16:29
Ruby program that asks the user for a number and prints the sum of the numbers 1 to the number he chose.
def sum_to
print 'Enter any number greater than 1: '
input = gets.to_i
sum = 0
for a in 1..input do
sum += a
end