Skip to content

Instantly share code, notes, and snippets.

View yisraeldov's full-sized avatar

Yisrael Dov Lebow yisraeldov

View GitHub Profile
@yisraeldov
yisraeldov / mime2ext.php
Last active December 13, 2016 15:14 — forked from alexcorvi/mime2ext.php
converting mime types to extension in php
<?PHP
function mime2ext($mime){
$all_mimes = '{"png":["image\/png","image\/x-png"],"bmp":["image\/bmp","image\/x-bmp","image\/x-bitmap","image\/x-xbitmap","image\/x-win-bitmap","image\/x-windows-bmp","image\/ms-bmp","image\/x-ms-bmp","application\/bmp","application\/x-bmp","application\/x-win-bitmap"],"gif":["image\/gif"],"jpeg":["image\/jpeg","image\/pjpeg"],"xspf":["application\/xspf+xml"],"vlc":["application\/videolan"],"wmv":["video\/x-ms-wmv","video\/x-ms-asf"],"au":["audio\/x-au"],"ac3":["audio\/ac3"],"flac":["audio\/x-flac"],"ogg":["audio\/ogg","video\/ogg","application\/ogg"],"kmz":["application\/vnd.google-earth.kmz"],"kml":["application\/vnd.google-earth.kml+xml"],"rtx":["text\/richtext"],"rtf":["text\/rtf"],"jar":["application\/java-archive","application\/x-java-application","application\/x-jar"],"zip":["application\/x-zip","application\/zip","application\/x-zip-compressed","application\/s-compressed","multipart\/x-zip"],"7zip":["application\/x-compressed"],"xml":["application\/xml","text\/xml"],
@yisraeldov
yisraeldov / build_postfields.php
Last active August 27, 2019 11:45
create an array that can be passed to `CURLOPT_POSTFIELDS` that contains mutidimension arrays and `CURLFile`s
<?php
/**
* Use this to send data with multidimensional arrays and CURLFiles
* `curl_setopt($ch, CURLOPT_POSTFIELDS, build_post_fields($postfields));`
*
* @param $data
* @param string $existingKeys - will set the paramater name, probably don't want to use
* @param array $returnArray - Can pass data to start with, only put good data here
*
* @return array
@yisraeldov
yisraeldov / s3example.php
Created December 20, 2016 16:10
Using s3 with flysystem and CacheControl
<?php
$loader = require __DIR__ . '/vendor/autoload.php';
$client = new Aws\S3\S3Client(
[
'credentials' => [
'key' => $key,
'secret' => $secret
],
'region' => 'eu-west-1',
'version' => 'latest',
@yisraeldov
yisraeldov / israepost.sh
Last active December 27, 2016 09:35 — forked from 0xItx/pkg_tracker.sh
Israel Post (דואר ישראל) command-line pacakge tracker
# -*- coding: utf-8 -*-
#!/bin/bash
for pkg in "$@"; do
echo -n "${pkg}: "
curl -s "http://www.israelpost.co.il/itemtrace.nsf/trackandtraceJSON?openagent&lang=EN&itemcode=${pkg}" |
python2 -c "import sys, locale, json; print (u' '+ json.load(sys.stdin)['itemcodeinfo'].split('<script')[0]).replace('<br>','').encode('utf8')"
done
@yisraeldov
yisraeldov / -
Created January 12, 2017 14:37
Ticker for bit2c for terminal
watch 'echo " [ `curl -s https://www.bit2c.co.il/Exchanges/BtcNis/Ticker.json` ]" | json_xs -t yaml'
@yisraeldov
yisraeldov / cpdiff
Last active January 16, 2017 09:32
Compare the primary selection with the clipboard.
diff <(xsel) <(xsel -b)
locker.sh &
nm-applet &
startxrandr &
skype &
pidgin &
pasystray &
compton &
hsetroot -add '#000000' -add '#808090' -add '#000000' -gradient 180
@yisraeldov
yisraeldov / gist:fe18b7606c82f1ff278cc982aa2e3326
Created April 2, 2017 15:02
FFMPEG make movie with waveform over static image.
ffmpeg -i <mp3>.mp3 -loop 1 -framerate 30 -i <png>.png -filter_complex "[a:0]showwaves=mode=p2p:r=30:size=465x353:,format=rgba,colorkey=black,colorchannelmixer=rr=0.003:gg=0.435:bb=0.133[fg];[1:v][fg]overlay=shortest=1,format=yuv420p,scale=852:-1,crop=iw:480[vid]" -map "[vid]" -map 0:a -c:a copy -shortest -c:v libx264 -preset fast -crf 32 /tmp/test.mkv
@yisraeldov
yisraeldov / MakePlaylist.sh
Created June 21, 2017 14:19
Make a playlist when scanning doesn't work.
playlist=/home/<user>/.config/retroarch/playlists/Sony - PlayStation.lpl
find /home/<user>/roms/Sony\ PlayStation/ -iname *.cue | while read f; do
echo $f;
echo $f >> "$playlist" ;
echo `basename "$f"` >> "$playlist";
echo DETECT >> "$playlist" ;
echo DETECT >> "$playlist" ;
echo `crc32 "$f"`"|crc" >> "$playlist";
echo `basename "$playlist"` >> "$playlist";
done
@yisraeldov
yisraeldov / keybase.md
Last active March 28, 2019 09:03
keybase.md

Keybase proof

I hereby claim:

  • I am yisraeldov on github.
  • I am yisraeldov (https://keybase.io/yisraeldov) on keybase.
  • I have a public key whose fingerprint is DEFB CFD0 01B4 45C1 C375 1CA0 6AE7 03B3 E171 C686

To claim this, I am signing this object: