Skip to content

Instantly share code, notes, and snippets.


Faramarz Salehpour fsalehpour

  • Fibernet
  • Gorgan, Golestan, Iran
View GitHub Profile
fsalehpour / today.zsh
Last active Sep 17, 2019
A zsh function that prints all the shell commands ran by the current user since the beginning of the today!
View today.zsh
#!/usr/bin/env zsh
function today (){
if [[ 0 -eq $# ]]; then
output=$(fc -lin -$lines)
php -r "copy('', 'composer-setup.php');"
ACTUAL_SIGNATURE="$(php -r "echo hash_file('sha384', 'composer-setup.php');")"
>&2 echo 'ERROR: Invalid installer signature'
rm composer-setup.php
fsalehpour / watermark.bash
Last active Nov 5, 2017
Script to add a scrolling watermark and scaling a video in one go using `ffmpeg`
View watermark.bash
(cd $1
mkdir -p output
for i in *
output="output/$(echo $i | sed 's/\..*$/\.mp4/')"
fsalehpour / alog.php
Last active Nov 2, 2017
regex to extract data from Apache's access log
View alog.php
$pattern = '/^([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}) \- \- \[([^\]]+)\] "([A-Z]+) ([^" ]+) [^"]*" ([0-9]+) ([0-9]+) "([^"]*)" "([^"]*)"/';
$heads = 'IP, timestamp, method, URI, status, size, referrer, agent' . PHP_EOL;
fputs(STDOUT, $heads);
while ($entry = fgets(STDIN)) {
preg_match($pattern, $entry, $segments);
fsalehpour /
Created Oct 15, 2016 — forked from iros/
Documenting your REST API


<Additional information about your API call. Try to use verbs that match both request type (fetching vs modifying) and plurality (one vs multiple).>

  • URL

    <The URL Structure (path only, no root url)>

  • Method:

View fontfriend.js
(function(A,f){var r,m,x,n="undefined",y={version:"3.2.3",css:"#font-friend{overflow:hidden;position:fixed;bottom:0;left:30px;background-color:#fff;background-color:rgba(255,255,255,0.93);width:740px;color:#222;-webkit-box-shadow:1px 1px 5px rgba(0,0,0,.3);-moz-box-shadow:1px 1px 5px rgba(0,0,0,.3);box-shadow:1px 1px 5px rgba(0,0,0,.3);z-index:10000;text-align:left;height:310px}#font-friend,#ff-drop h6,#ff-drop li{line-height:1.5!important}#ff-drop{padding:12px 12px 12px 36px}#ff-toggle{background-color:#222;color:#eee;display:block;width:12px;height:16px;padding:0 1px 0 3px;position:absolute;top:0;left:0;font-size:16px;line-height:1!important;cursor:pointer;z-index:10001;-moz-transition:.25s all ease-in-out;-webkit-transition:.25s all ease-in-out;-o-transition:.25s all ease-in-out;transition:.25s all ease-in-out}#ff-toggle sup{font-size:13px;line-height:1!important;vertical-align:super;display:none}.open #ff-toggle sup{display:inline}#ff-toggle:hover{color:#fff;background-color:#555}.open #ff-toggle{width:au
fsalehpour / sqllog-laravel4.php
Last active Dec 25, 2015
SQL query logging for Laravel 4. Put it somewhere to run, like app/filters.php. Thanks to Shawn McCool
View sqllog-laravel4.php
// Logs SQL queries as info
// Thanks to @ShawnMcCool
// Link to the original content by Shawn McCool:
Event::listen('illuminate.query', function($sql, $bindings)
foreach ($bindings as $val) {
fsalehpour / ytdl.bash
Created Sep 19, 2013
Youtube downloader using youtbue-dl
View ytdl.bash
python2.6 $HOME/bin/youtube-dl -F $1
echo -n "Enter the number of your file format choice: "
read format
python2.6 $HOME/bin/youtube-dl -t -f $format $1
View troublesome
private static function sendDeleteRq($h, $u) {
$client = new Client();
$rq = $client->delete($u, array('h' => $h));
$mn = $rq->send();
return $mn;
fsalehpour / sort.cpp
Created Jun 8, 2011
Sorting using array in an object
View sort.cpp
* P:#33
* Write a programme to sort n numbers.
#include <iostream.h>
#include <conio.h>
class Array