Skip to content

Instantly share code, notes, and snippets.

@0xjams
0xjams / phantomjs_screenshots_urls.js
Last active December 2, 2015 17:09
A script to use Phantomjs to get screenshots of an array of urls.
var urls=["https://reddit.com","https://facebook.com"];
var page = require('webpage').create();
page.urls=urls;
console.log("Working with " + page.urls.length + " urls");
page.currentIndex=0;
page.nextScreenshot=function(){
console.log("Getting screenshot of: " + page.urls[page.currentIndex]);
page.open(page.urls[page.currentIndex], function(status) {
console.log("Status: " + status);
if(status === "success") {
@0xjams
0xjams / generate_csr.sh
Created June 18, 2015 22:58
Generate a certificate signing request
openssl req -nodes -sha256 -newkey rsa:2048 -keyout domain.com.key -out domain.com.csr
@0xjams
0xjams / isDesktopBrowser.php
Created June 8, 2015 18:28
Validate if the user agent belongs to a desktop client
function isDesktopBrowser(){
if((strpos(strtolower($_SERVER["HTTP_USER_AGENT"]),"windows")!==false && strpos(strtolower($_SERVER["HTTP_USER_AGENT"]),"windows phone")===false) or (strpos(strtolower($_SERVER["HTTP_USER_AGENT"]),"linux")!==false && strpos(strtolower($_SERVER["HTTP_USER_AGENT"]),"android")===false) or strpos(strtolower($_SERVER["HTTP_USER_AGENT"]),"macintosh")!==false)
{
return true;
}
return false;
}
@0xjams
0xjams / convert_videos_radio_compatible.py
Created June 6, 2015 01:19
Batch convert video files to a format compatible with a Pioneer 5700BHS radio
import glob
import os
files=glob.glob("*.mp4")
for file in files:
outputName=file.replace(".mp4",".avi")
os.system("ffmpeg -i \"%s\" -c:v mpeg4 -q:v 5 -tag:v DIVX -s 640x480 -c:a libmp3lame -q:a 5 -ac 2 -ar 44100 \"%s\"" % (file,outputName))
@0xjams
0xjams / random_fortune.sh
Created March 29, 2015 23:31
Random fortune with a random format cowsay
#!/bin/bash
formats=$(cowsay -l)
words=$(echo $formats | wc -w)
format=$(($RANDOM%($words-5)))
str_format=$(echo $formats | cut -d" " -f $(($format+5)))
fortune ~/fortunes/facts_complete.dat | cowsay -f $str_format

Keybase proof

I hereby claim:

  • I am jorgejams88 on github.
  • I am jorgemoran (https://keybase.io/jorgemoran) on keybase.
  • I have a public key whose fingerprint is 901E 13AE 65D3 FD86 9F71 E8CF 7C87 E253 B15E 7F76

To claim this, I am signing this object: