Skip to content

Instantly share code, notes, and snippets.

View Igzak's full-sized avatar
🎯
Focusing

Igzak

🎯
Focusing
View GitHub Profile
@pocesar
pocesar / get domain without subdomain.php
Created April 11, 2013 20:27
PHP code to get the domain name without subdomains (includes the tld, and the special types from IANA). Don't have support for unicode domain names.
<?php
/**
* @param string $domain Pass $_SERVER['SERVER_NAME'] here
* @param bool $debug
*
* @debug bool $debug
* @return string
*/
function get_domain($domain, $debug = false)
{
@lukaswhite
lukaswhite / ClearBeanstalkdQueueCommand.php
Last active March 20, 2023 08:11
Clear a Beanstalkd Queue in Laravel
<?php
use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
class ClearBeanstalkdQueueCommand extends Command {
/**
@brenopolanski
brenopolanski / merge-pdf-ghostscript.md
Last active September 28, 2024 22:54
Merge multiple PDFs using Ghostscript

A simple Ghostscript command to merge two PDFs in a single file is shown below:

gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=combine.pdf -dBATCH 1.pdf 2.pdf

Install Ghostscript:

Type the command sudo apt-get install ghostscript to download and install the ghostscript package and all of the packages it depends on.

@craigbeck
craigbeck / introspection-query.graphql
Created April 6, 2016 20:20
Introspection query for GraphQL
query IntrospectionQuery {
__schema {
queryType { name }
mutationType { name }
subscriptionType { name }
types {
...FullType
}
directives {
@olastor
olastor / obfuscate.js
Last active November 4, 2024 09:57
Simple algorithm to quickly obfuscate a string in javascript.
/**
* Obfuscate a plaintext string with a simple rotation algorithm similar to
* the rot13 cipher.
* @param {[type]} key rotation index between 0 and n
* @param {Number} n maximum char that will be affected by the algorithm
* @return {[type]} obfuscated string
*/
String.prototype.obfs = function(key, n = 126) {
// return String itself if the given parameters are invalid
if (!(typeof(key) === 'number' && key % 1 === 0)
PPA:
sudo add-apt-repository ppa:ondrej/php-zts || sudo add-apt-repository ppa:nhojohl/php7-zts
sudo apt-get update
sudo apt-get install php7.0-zts php7.0-zts-dev
PHTHREADS:
cd ~/
git clone git://github.com/krakjoe/pthreads.git
cd pthreads
@troatie
troatie / CreatesWithLock.php
Last active September 12, 2023 13:51
Guard against race conditions in Laravel's firstOrCreate and updateOrCreate
trait CreatesWithLock
{
public static function updateOrCreate(array $attributes, array $values = [])
{
return static::advisoryLock(function () use ($attributes, $values) {
// emulate the code found in Illuminate\Database\Eloquent\Builder
return (new static)->newQuery()->updateOrCreate($attributes, $values);
});
}
// ==UserScript==
// @name Spotify ad skipper
// @version 1.0
// @namespace http://tampermonkey.net/
// @description Detects and skips ads on spotify
// @match https://*.spotify.com/*
// @grant none
// @run-at document-start
// @downloadURL https://gist.githubusercontent.com/Simonwep/24f8cdcd6d32d86e929004013bd660ae/raw
// @updateURL https://gist.githubusercontent.com/Simonwep/24f8cdcd6d32d86e929004013bd660ae/raw
@NHZEX
NHZEX / WebSocketClient
Created May 11, 2019 09:29
Swoole WebSocket Client
<?php
use Exception;
use Swoole\Client;
use Swoole\WebSocket\Server;
// https://github.com/swoole/swoole-src/blob/master/examples/websocket/WebSocketClient.php
class WebSocketClient
{
const VERSION = '0.1.4';
@Jabarabo
Jabarabo / githubpull.md
Last active November 15, 2024 13:53
Gist of a stolen gist