Skip to content

Instantly share code, notes, and snippets.

View atefBB's full-sized avatar
🎯
Focusing

Atef Ben Ali atefBB

🎯
Focusing
View GitHub Profile
@ollieread
ollieread / filters.php
Created January 7, 2014 18:00
Replacing the default auth filter with one for multiauth
<?php
// original auth filter
Route::filter('auth', function()
{
if (Auth::guest()) return Redirect::guest('login');
});
// new multiauth filter
Route::filter('auth', function()
{
$.ajax({
method: POST,
url: my.app.dev/users/1,
data: { name: "Matt"}
})
.done(function () {
// whatever you normally do here
})
.fail(function (res) {
if (res.status !== 422) {
@davemo
davemo / bootstrap.js
Last active November 16, 2017 13:23
injectorsauce
(function() {
var $injector = angular.injector(['ng']);
$injector.invoke(function($http) {
// this works!
$http.get("/auth/csrf_token").then(function(response) {
angular.module("app").constant("CSRF_TOKEN", response.csrf_token);
angular.bootstrap(document, ['app']);
});
@noeldiaz
noeldiaz / gist:0f9a2583a41579878764
Created July 18, 2014 15:56
Homestead 32-bit Version
## Making a 32 bit version of Homestead
# Clone the settler repository to a directory
git clone https://github.com/laravel/settler.git Ubuntu32
# In that directory edit the file called "Vagrantfile" to use a ubuntu 32 box instead of the 64 bit one
change this line:
config.vm.box = "ubuntu/trusty64"
@Majkl578
Majkl578 / Dockerfile
Last active November 8, 2019 17:41
Dockerized example for article at Pehapkari.cz about running multiple PHP versions: https://pehapkari.cz/blog/2017/03/27/multiple-php-versions-the-easy-way/
FROM debian:stretch
ENV DEBIAN_FRONTEND noninteractive
# install NGINX
RUN apt-get update && \
apt-get install -y nginx --no-install-recommends && \
rm -rf /var/lib/apt/lists/*
@ziadoz
ziadoz / scrape.php
Created August 13, 2012 21:54
Scraping Google using PHP and Goutte:
<?php
/**
* Todo: Send a random user agent string and sleep a random amount between requests.
*/
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// Extract and sanatize input:
$domain = filter_input(INPUT_POST, 'domain', FILTER_SANITIZE_URL);
$terms = filter_input(INPUT_POST, 'terms', FILTER_SANITIZE_STRING);
// Setup Goutte (which also includes Guzzle):
@sisou
sisou / CronRunCommand.php
Last active June 18, 2022 10:29
Cron job command for Laravel 4.2
<?php
# Cron job command for Laravel 4.2
# Inspired by Laravel 5's new upcoming scheduler (https://laravel-news.com/2014/11/laravel-5-scheduler)
#
# Author: Soren Schwert (GitHub: sisou)
#
# Requirements:
# =============
# PHP 5.4
@oanhnn
oanhnn / how_to.md
Created May 14, 2017 16:47
How to fix composer error "Content-Length Mismatch"

First, run:

$ composer config --list --global        //this will get the composer home path.
[home] /root/.composer                   //it's my composer home path.

And then, edit the config.json in [home] directory, make it like this:

{
  "config": {
 "github-protocols": [
@megaxorg
megaxorg / PHP-CURL-Tor-Tutorial.md
Last active December 2, 2022 20:23
PHP: CURL Requests with Tor

#CURL Connections with Tor

Install Apache, PHP, CURL & Tor with apt-get

sudo apt-get install -y apache2 php5 php5-curl tor

Tor creates a proxy on your mashine with port 9050 for SOCKS5 connections.

@adamwathan
adamwathan / promise-take-at-least.js
Last active February 26, 2023 14:25
Promise.takeAtLeast
// Creates a new promise that automatically resolves after some timeout:
Promise.delay = function (time) {
return new Promise((resolve, reject) => {
setTimeout(resolve, time)
})
}
// Throttle this promise to resolve no faster than the specified time:
Promise.prototype.takeAtLeast = function (time) {
return new Promise((resolve, reject) => {