Skip to content

Instantly share code, notes, and snippets.

View spacemudd's full-sized avatar
🎯
Focusing

Shafiq al-Shaar spacemudd

🎯
Focusing
View GitHub Profile
@sparkcodeuk
sparkcodeuk / floating-ip-gateway.sh
Created March 2, 2018 21:47
Digital Ocean floating IP gateway script (force droplet to use the assigned floating IP for outbound traffic as well as inbound traffic)
#!/bin/bash
# Force outbound traffic through the attached floating IP
NET_INT="eth0"
CURL_TIMEOUT=3
echo -n "Setting floating IP as the default gateway: "
# Check there's a floating IP attached to this droplet
if [ "$(curl -s --connect-timeout $CURL_TIMEOUT http://169.254.169.254/metadata/v1/floating_ip/ipv4/active)" != "true" ]; then
@d0x2f
d0x2f / .drone.yml
Last active August 17, 2021 22:18
.drone.yml example
workspace:
base: /build
pipeline:
dbnode1:
detach: true
image: mysql/mysql-cluster:7.5
commands:
- sleep 5
@ivan-pinatti
ivan-pinatti / jenkins-set-digitalocean-plugin-parameters.groovy
Last active November 17, 2022 04:43
Jenkins - Set Digitalocean slaves plugin parameters via groovy script - #jenkins #groovy #jenkins-digitalocean #jenkins-slaves #jenkins-slave
#!groovy
// imports
import com.dubture.jenkins.digitalocean.DigitalOceanCloud
import com.dubture.jenkins.digitalocean.SlaveTemplate
import jenkins.model.Jenkins
// parameters
def slaveTemplateParameters = [
idleTerminationInMinutes: '10',
@koenhoeijmakers
koenhoeijmakers / axios.js
Created December 14, 2017 09:37
Axios interceptor to fix PUT (multipart/form-data) requests to a PHP back-end
/**
* Request interceptor that fixes PUT requests for php. >> https://bugs.php.net/bug.php?id=55815
*/
instance.interceptors.request.use((request) => {
if (request.method === 'put' && request.data instanceof FormData) {
request.method = 'post';
request.data.append('_method', 'put');
}
return request;
@pizzavomito
pizzavomito / CsvReader.php
Last active May 4, 2021 04:45
Reading CSV file with SplFileObject. Define a header or manage the header line from CSV file. Returns rows in arrays with header values as array keys.
<?php
/**
* MIT License
*
* Copyright (c) 2017 Pascal Roux
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
@Artistan
Artistan / EloquentUser.php
Last active August 21, 2024 14:40
Paginator with relations... load the relations on the model
<?php
namespace App;
use Illuminate\Pagination\LengthAwarePaginator;
use App\Http\Controllers\Controller;
class EloquentUser extends Controller {
// these will work for eloquent, but not with a scout->search since scout is not building a query.
public function paginate($query)
@DiKorsch
DiKorsch / run.py
Last active August 16, 2022 12:09
Scan files under Windows and save them under filename present in the clipboard
"""
- python2.7 32bit installieren (https://www.python.org/ftp/python/2.7.12/python-2.7.12.msi)
- C:\python\pip install pyperclip twain pillow
- C:\python\python.exe run.py
"""
import pyperclip, twain, os
from os.path import isdir, isfile, dirname, abspath
from PIL import Image
@JacobBennett
JacobBennett / blog.md
Last active September 4, 2024 18:48
Clean up your Vue modules with ES6 Arrow Functions

Recently when refactoring a Vue 1.0 application, I utilized ES6 arrow functions to clean up the code and make things a bit more consistent before updating to Vue 2.0. Along the way I made a few mistakes and wanted to share the lessons I learned as well as offer a few conventions that I will be using in my Vue applications moving forward.

The best way to explain this is with an example so lets start there. I'm going to throw a rather large block of code at you here, but stick with me and we will move through it a piece at a time.

<script>

// require vue-resource...

new Vue({
@artemgordinskiy
artemgordinskiy / node-npm-in-docker.sh
Created December 11, 2015 14:00
Run Node/NPM in a Docker container
# For example, run "npm install"
docker run -v "$PWD":/usr/src/app -w /usr/src/app node:4 npm install
# This command creates a container (downloading one first if you don't have it locally), runs the command in a current directory and quits the container
# Great Success!
@ivanvermeyen
ivanvermeyen / EnsureQueueListenerIsRunning.php
Last active February 13, 2024 12:40
Ensure that the Laravel queue listener is running with "php artisan queue:checkup" and restart it if necessary. You can run this automatically with a cron job: http://laravel.com/docs/scheduling
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
class EnsureQueueListenerIsRunning extends Command
{
/**
* The name and signature of the console command.