Skip to content

Instantly share code, notes, and snippets.

View chiqui3d's full-sized avatar
😊
Out sick

José Carlos chiqui3d

😊
Out sick
View GitHub Profile
/**
* @file chat_epoll_server.c (part 1)
* @author chiqui3d
* @brief Simple server with socket y and epoll with edge triggered mode (nonblocking) to handle multiple clients
* @version 0.1
* @date 2022-07-01
*
* @references
*
* * https://web.archive.org/web/20160325155925/https://banu.com/blog/2/how-to-use-epoll-a-complete-example-in-c/
@chiqui3d
chiqui3d / resize.sh
Last active March 25, 2021 19:58
Resize and compress in Bulk with Google's image recommendations with the super ImageMagick
# Search for images in any directory where the script is executed $(pwd) and compress and resize them
# Change to your liking
# echo $1 # parameter
# echo $(pwd); # current directory where script is run
find "$(pwd)" \( -iname \*.jpg -o -iname \*.jpeg \) -print0 | while read -r -d $'\0' file; do
name="${file##*/}" # Name with extension
directory="${file%/*}" # Image directory without image name :)
newname="$(echo $name | sed 's/ /-/g' | awk '{print tolower($0)}')" # Image name without spaces and lower
@chiqui3d
chiqui3d / gulpfile.js
Last active December 25, 2021 09:59
Gulpfile to deploy Symfony or Laravel projects with SSH
var gulp = require('gulp');
var rsync = require('gulp-rsync');
var GulpSSH = require('gulp-ssh')
var fs = require('fs');
var shell = require('gulp-shell');
var dotenv = require('dotenv');
var parseDbUrl = require("parse-database-url");
/**
* DEPLOY
@chiqui3d
chiqui3d / es6_fetch_example.js
Created June 1, 2018 23:05 — forked from robvolk/es6_fetch_example.js
AJAX requests in ES6 using fetch()
// ES6 Fetch docs
// https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch
fetch('https://some.url.com')
.then(response => {
if (response.ok) {
return Promise.resolve(response);
}
else {
return Promise.reject(new Error('Failed to load'));
@chiqui3d
chiqui3d / scrape.php
Created December 13, 2015 01:12 — forked from ziadoz/scrape.php
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):
@chiqui3d
chiqui3d / 404checker.js
Created October 30, 2015 14:19 — forked from n1k0/404checker.js
A CasperJS script to check for 404 & 500 internal links on a given website
/**
* This casper scipt checks for 404 internal links for a given root url.
*
* Usage:
*
* $ casperjs 404checker.js http://mysite.tld/
* $ casperjs 404checker.js http://mysite.tld/ --max-depth=42
*/
/*global URI*/
@chiqui3d
chiqui3d / download.sh
Last active March 12, 2019 18:54 — forked from mildred/download.sh
Download from archive.org Wayback Machine
#!/bin/bash
url=http://redefininggod.com
webarchive=https://web.archive.org
wget="wget -e robots=off -nv"
tab="$(printf '\t')"
additional_url=url.list
# Construct listing.txt from url.list
# The list of archived pages, including some wildcard url
for FILENAME in *;
do mysql -u user -pMyPass < $FILENAME;
done
<?PHP
/**
* Spintax - A helper class to process Spintax strings.
* @name Spintax
* @author Jason Davis - https://www.codedevelopr.com/
* Tutorial: https://www.codedevelopr.com/articles/php-spintax-class/
*/
class Spintax
{
public function process($text)
<?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):