Skip to content

Instantly share code, notes, and snippets.

View jasperf's full-sized avatar
🏠
Working from home

Jasper Frumau jasperf

🏠
Working from home
View GitHub Profile
[{"key":"1920 x 1080","name":"Nexus 5 Landscape","width":1920,"height":1080},
{"key":"1080 x 1920","name":"Nexus 5 Portrait","width":1080,"height":1920},
{"key":"1024 x 768","name":"iPad Landscape","width":1024,"height":768},
{"key":"768 x 1024","name":"iPad Portrait","width":768,"height":1024},
{"key":"736 x 414","name":"iPhone 6 Plus Landscape","width":736,"height":414},
{"key":"414 x 736","name":"iPhone 6 Plus Portrait","width":414,"height":736},
{"key":"667 x 375","name":"iPhone 6 Landscape","width":667,"height":375},
{"key":"375 x 667","name":"iPhone 6 Portrait","width":750,"height":1334},
{"key":"568 x 320","name":"iPhone 5/S/C Landscape","width":568,"height":320},
{"key":"320 x 568","name":"iPhone 5/S/C Portrait","width":320,"height":568},
@jasperf
jasperf / setgid
Last active August 29, 2015 14:07
Add user created files and directories to group apache (or other) to make it accesible by scripts when using Mod PHP #apache #permissions
//Do not forget to add user to group Apache as well to prevent other issues with server uploaded content
//add existing user to group x keeping user's first group as primary
# usermod -a -G apache user
//Make Apache and Mod PHP create files with group write permissions
//see http://stackoverflow.com/questions/428416/setting-the-umask-of-the-apache-user
root ~]$ echo "umask 002" >> /etc/sysconfig/httpd
[root ~]$ service httpd restart
// Set Group ID where user will create content to make it belong to group directory is in.
//Useful to allow Mod PHP to run scripts
chmod g+s /path/to/directory/
@jasperf
jasperf / TTFB
Last active August 29, 2015 14:07
Time To First Byte or TTFB #networking #curl
//http://haydenjames.io/analyze-websites-ttfb-time-first-byte/
//should be below a second
curl -o /dev/null -w "Connect: %{time_connect} TTFB: %{time_starttransfer} Total time: %{time_total} \n" http://site.com
@jasperf
jasperf / curl-grab-file
Created October 5, 2014 07:43
Grab / download a file using curl and making sure redirects work in case this takes place #curl #download
curl -O -L https://www.dropbox.com/s/x/file.zip
@jasperf
jasperf / tr-find-word-frequency
Created November 6, 2014 09:27
Find the word frequency in any text file using tr #find #tr #seo
//1.19.2 is version on OSX Yeosemite. The file is used to make sure stop words are filtered out
//https://unix.stackexchange.com/questions/41479/find-n-most-frequent-words-in-a-file
tr -c '[:alnum:]' '[\n*]' < file.txt | fgrep -v -f /usr/share/groff//1.19.2/eign | sort | uniq -c | sort -nr | head -10
@jasperf
jasperf / rm-macports-leftovers
Created November 24, 2014 06:46
Remove MacPorts Remains #osx #macports
sudo rm -rf \ /opt/local \ /Applications/DarwinPorts \ /Applications/MacPorts \ /Library/LaunchDaemons/org.macports.* \ /Library/Receipts/DarwinPorts*.pkg \ /Library/Receipts/MacPorts*.pkg \ /Library/StartupItems/DarwinPortsStartup \ /Library/Tcl/darwinports1.0 \ /Library/Tcl/macports1.0 \ ~/.macports
@jasperf
jasperf / vhost file to automatically generate vhosts.md
Last active August 29, 2015 14:10
Virtualhost File to automatically generate vhost files for new sites added to specific folder #apache #vhosts

//http://dsheiko.com/weblog/my-lovely-mac-os-x-web-development-environment ###loaded from /private/etc/apache2/extra/httpd-vhosts.conf which is loaded by main conf file <Virtualhost *:80> VirtualDocumentRoot "/Users/jasper/webdesign/%1" ServerName vhosts.dev ServerAlias *.dev UseCanonicalName Off LogFormat "%V %h %l %u %t "%r" %s %b" vcommon ErrorLog "/Users/jasper/webdesign/vhosts-error_log"

<?php
eval(
function get_page($url){
//start cURL session with url $url
$ch = curl_init ();
curl_setopt ($ch, CURLOPT_URL,$url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_TIMEOUT, 30);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
@jasperf
jasperf / htacess-authentication
Last active August 29, 2015 14:16
.Htacces Authentication
ErrorDocument 401 default
AuthType Basic
AuthName "Enter login two times and then regular password"
AuthUserFile /home/user/domain.com/.htpasswd
Require valid-user