Skip to content

Instantly share code, notes, and snippets.

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

faryar faryar76

🏠
Working from home
View GitHub Profile
@odan
odan / xampp_php7_xdebug.md
Last active April 9, 2025 13:07
Installing Xdebug for XAMPP
@florian-wagner
florian-wagner / pre-push
Created October 5, 2015 14:21
Git-hook giving a warning when you try to push to the 'master' branch.
#!/bin/bash
# Save this file as gimli/.git/hooks/pre-push and make it executable.
protected_branch='master'
current_branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,')
if [ $protected_branch = $current_branch ]
then
read -p "GIMLi encourages developers to push only to the 'dev' branch. You're about to push to 'master', is that what you intended? [y|n] " -n 1 -r < /dev/tty
echo
@joashp
joashp / openssl_encrypt_decrypt.php
Created September 4, 2015 15:59
Simple PHP encrypt and decrypt using OpenSSL
<?php
/**
* simple method to encrypt or decrypt a plain text string
* initialization vector(IV) has to be the same when encrypting and decrypting
*
* @param string $action: can be 'encrypt' or 'decrypt'
* @param string $string: string to encrypt or decrypt
*
* @return string
*/
@JeffreyWay
JeffreyWay / countries.php
Created July 23, 2015 17:01
Country Names + Codes
[
"United States" => "us",
"Afghanistan" => "af",
"Albania" => "al",
"Algeria" => "dz",
"American Samoa" => "as",
"Andorra" => "ad",
"Angola" => "ad",
"Anguilla" => "ai",
"Antarctica" => "aq",
@ahmadazimi
ahmadazimi / replace-zero-width-space.php
Last active April 23, 2025 08:54
PHP replace Zero Width Space using preg_replace
<?php
/**
* http://stackoverflow.com/questions/11305797/remove-zero-width-space-characters-from-a-javascript-string
* U+200B zero width space
* U+200C zero width non-joiner Unicode code point
* U+200D zero width joiner Unicode code point
* U+FEFF zero width no-break space Unicode code point
*/
package regex;
import org.junit.Test;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static regex.CronRegex.Field.*;
import static java.util.Arrays.asList;
@mcorrigan
mcorrigan / POST Request with File Resource
Last active October 10, 2022 10:42
Creating a POST request using file handlers for file content
<?php
# base code found here: http://stackoverflow.com/questions/3085990/post-a-file-string-using-curl-in-php
$delimiter = '----WebKitFormBoundary'.uniqid();
$data = create_post($delimiter, array(
'bingo' => 'yes'
), array(
'file' => array(
'filename' => 'data.txt',
@lgalaz
lgalaz / gist:aec80abd40350161ff63
Last active July 12, 2022 02:18
Server sent events with Laravel
Using nginx version: nginx/1.6.2 and Laravel 5
In the controller:
use Symfony\Component\HttpFoundation\StreamedResponse;
- - - - - - Some method - - - - - - - - -
$response = new StreamedResponse();
$response->headers->set('Content-Type', 'text/event-stream');
$response->headers->set('Cache-Control', 'no-cache');
$response->setCallback(
function() {
@ssigwart
ssigwart / buildMultipartFormData.php
Created January 24, 2015 16:21
Build multipart/form-data in PHP
/**
* Build multipart/form-data
*
* @param array @$data Data
* @param array @$files 1-D array of files where key is field name and value if file contents
* @param string &$contentType Retun variable for content type
*
* @return string Encoded data
*/
function buildMultipartFormData(array &$data, array &$files, &$contentType)
@idleberg
idleberg / fish_shell.md
Last active February 25, 2025 01:21
Instructions on how to install Fish shell on Mac OS X, including Oh My Fish!. Also includes several useful functions.

Installation

  1. Install fish via Brew
  2. Optionally install Oh My Fish!
  3. Add fish to known shells
  4. Set default shell to fish
brew install fish  
curl -L https://get.oh-my.fish | fish