Skip to content

Instantly share code, notes, and snippets.

View spelcaster's full-sized avatar

Hugo do Carmo spelcaster

  • NoCartorio.com
  • Minas Gerais
View GitHub Profile
@spelcaster
spelcaster / get_jenkins_plugins.sh
Last active July 21, 2016 14:07
Script to download jenkins plugins using jenkins-cli in command line
#!/bin/bash
# This script should be used to download the most recent plugins for jenkins in command line
# You need Jenkins CLI (https://wiki.jenkins-ci.org/display/JENKINS/Jenkins+CLI) to use this script
JENKINS_CLI_JAR=/path/to/jenkins-cli.jar
JENKINS_PLUGIN_URL=http://updates.jenkins-ci.org/latest/
JENKINS_PLUGIN_EXT=.hpi
JENKINS_PLUGIN_TMP=/tmp/jenkins/plugin
LIST_PLUGINS_CMD="java -jar ${JENKINS_CLI_JAR} -s http://localhost:8080/ list-plugins"
@spelcaster
spelcaster / nic_mac_list_by_vendor_device.sh
Created August 12, 2016 14:27
Get interface name and mac address grouped by vendor and device
#!/bin/bash
OLDIFS=$IFS
IFS=$'\n'
mapfile -t NIC_MODEL < <(lspci | grep -i ethernet | sed 's@[[:alnum:]]\+:[[:alnum:]]\+\.[[:alnum:]]\+\s*@@' | uniq)
IFS=${OLDIFS}
for (( i=0; i < ${#NIC_MODEL[@]}; i++ ))
do
@spelcaster
spelcaster / mongod.conf.mmapv1
Last active April 6, 2020 02:08
Scripts to configure a mongodb environment
storage:
dbPath: /var/lib/mongodb
repairPath: /var/lib/mongodb/.repair
directoryPerDB: true
journal:
enabled: true
engine: "mmapv1"
mmapv1:
smallFiles: true
@spelcaster
spelcaster / one-shot-server.service
Last active June 7, 2021 01:45
Use netcat to serve a file through HTTP
[Unit]
Description=One shot server using netcat
After=network.target
[Service]
Type=simple
PIDFile=/run/one_shot_server.pid
Restart=on-failure
Environment="PORT=4000"
Environment="FILE=/tmp/somefile.json"
<?php
abstract class A
{
public function inheritance()
{
return self::p();
}
public function inheritance2()
@spelcaster
spelcaster / webpack.config.babel.js
Last active July 5, 2017 14:29
This is my default webpack config file
import path from 'path'
import ExtractTextPlugin from 'extract-text-webpack-plugin'
const extractSass = new ExtractTextPlugin({
filename: 'style/bundle.css',
disable: process.env.NODE_ENV === 'development'
})
const rules = {
sass: {
@spelcaster
spelcaster / generate_helptags.sh
Created July 31, 2017 15:28
Generate helptags for plugins under `bundle` directory
#!/bin/bash
echo "Generating helptags"
echo
while IFS= read -r -d $'\0' docDir <&3; do
echo "Generating helptags for '$docDir'..."
vim -u NONE -c "helptags $docDir" -c q
@spelcaster
spelcaster / install_react_i18next_namespaces.sh
Created September 3, 2017 03:27
This script is used to copy locale files from app source directory to public directory.
#!/bin/bash
SRC_DIR=${1}
LOCALES_DIR=${2}
echo "Installing locales"
echo
while IFS= read -r -d $'\0' localeDir <&3; do
echo "Installing locales from '${localeDir}'..."
@spelcaster
spelcaster / daemon_sample
Created September 29, 2017 03:19
Simple PHP daemon using double fork
#!/usr/bin/php
<?php
// ##### definitions #####
define("DAEMON_NAME", "daemon-sample");
define("DAEMON_ROOT", "/tmp/daemon-sample");
define("DAEMON_PID", "/run/daemon-sample.pid");
define("DAEMON_LOG", "/tmp/daemon-sample/logfile");
// uid and gid from http|www-data user
@spelcaster
spelcaster / sync_base64.js
Created October 17, 2017 18:19
Read a file synchronously and parse it to base64 using the builtin Buffer class
var fs = require('fs');
const gMinLength = 3;
const gFile = '/tmp/test';
const gEncoding = 'ascii';
function sample1() {
var data = fs.readFileSync(gFile);
var buff = Buffer.from(data, gEncoding);