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 / Jenkinsfile
Created December 29, 2020 13:10 — forked from lferro9000/Jenkinsfile
Jenkinsfile with PHP pipeline for Jenkins 2
#!/usr/bin/env groovy
node('php') {
stage('Get code from SCM') {
checkout(
[$class: 'GitSCM', branches: [[name: '*/#your-dev-branch#']],
doGenerateSubmoduleConfigurations: false,
extensions: [],
submoduleCfg: [],
@spelcaster
spelcaster / prepare-commit-msg
Created May 1, 2019 11:22
Git Hooks for PHP projects
#!/bin/bash
retval=0
while read -r filepath; do
vendor/bin/phplint "$filepath"
retval=$(( $retval + $? ))
done < <(git diff --cached --name-status | awk '$1 != "D" { print $2 }' | grep ".php")
if [[ $retval -gt 0 ]]; then
echo "PHP Syntax error found"
@spelcaster
spelcaster / instructions.md
Last active January 14, 2019 13:20
fix xorg low resolution

If cat /var/log/Xorg.0.log | grep -P "Mode is rejected: (Vert|Horiz)", then you probably need to update the monitor section in your xorg.conf.

Example:

Section "Monitor"     
    Identifier     "Dell-P2414Hb"    
    VendorName     "DELL"       
    ModelName      "P2414Hb"             
 
@spelcaster
spelcaster / .clang-format-default
Created June 29, 2018 20:32
Default clang-format configuration
---
# http://clang.llvm.org/docs/ClangFormatStyleOptions.html
Language: Cpp
AccessModifierOffset: -2
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Right
AlignOperands: true
AlignTrailingComments: true
@spelcaster
spelcaster / 49659511.js
Created April 5, 2018 13:10
Construct new array of objects from object array
let response = [
{
title: "Map marker 1",
lat: 10.0,
lng: 10.0
},
{
title: "Map marker 2",
lat: 11.0,
lng: 11.0
@spelcaster
spelcaster / create_avd_from_command_line.sh
Last active March 14, 2018 19:22
Create and launch AVD from command line
# https://stackoverflow.com/questions/43275238/how-to-set-system-images-path-when-creating-an-android-avd/43522262
# download img
sdkmanager 'system-images;android-23;google_apis;x86_64'
# accept the sdk license
sdkmanager --licenses
# create AVD
avdmanager create avd -n {avd_name} -k "system-images;android-23;google_apis;x86_64" -b x86_64 -c 100M -d 7 -f
@spelcaster
spelcaster / .tern-project
Last active November 27, 2017 15:35
This is a default .tern-project file
{
"libs": [ "browser", "ecma6", "ecma5" ],
"loadEagerly": [],
"dontLoad": ["node_modules"],
"plugins": {
"angular": {},
"complete_strings": true,
"doc_comment": true,
"modules": true,
"node": true,
@spelcaster
spelcaster / php.snippets
Last active November 16, 2017 13:07
Vim Snippets for Symfony (PHP)
snippet docc "Symfony Entity attribute with doctrine annotation"
/**
* @ORM\Column(type="${2:string}"${3:, length=${4:25}}${5:, unique=${6:true}}${7:, nullable=${8:false}})
*
* @var ${9:$2}
*/
protected $${1:attr};
endsnippet
snippet doc11 "Symfony Entity attribute with Doctrine association mapping 1-1"
@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);
@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