Skip to content

Instantly share code, notes, and snippets.

View dmarcelino's full-sized avatar

Dário dmarcelino

  • AppsCot
  • Lisbon, Portugal
View GitHub Profile
@dmarcelino
dmarcelino / angular.adsense.js
Created May 22, 2015 11:07
Angular adsense example that shows ad more than 3 times
'use strict';
var adSenseTpl = '<div id="adsenses-ad-1"><ins class="adsbygoogle"' +
'style="display:inline-block;width:336px;height:280px"' +
'data-ad-client="ca-pub-000000000000000000"' +
'data-ad-slot="00000000000"></ins></div>';
var adsenseAd1;
angular.module('MyApp')
@dmarcelino
dmarcelino / search_backends.py
Created August 6, 2016 21:39 — forked from gregplaysguitar/folding_whoosh_backend.py
Django-haystack Whoosh backend with character folding
# -*- coding: utf-8 -*-
"""
Whoosh backend for haystack that implements character folding, as per
http://packages.python.org/Whoosh/stemming.html#character-folding .
Tested with Haystack 2.4.0 and Whooch 2.7.0
To use, put this file on your path and add it to your haystack settings, eg.
@dmarcelino
dmarcelino / True Trello Printer
Created September 22, 2016 08:29 — forked from mathiasrw/True Trello Printer
Ever wanted to print your Trello board? Export as JSON and paste it into the code.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>True Trello Printer</title>
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet">
<style>
body{margin:15%;}
.panel-body{
Sometimes after a hard reboot (power cut), if your synology cannot be logged in with DSM and it shows "System is getting ready. Please log in later" , please do these steps :
#Admin login via ssh
> synobootseq --set-boot-done
> synobootseq --is-ready
#optional
> /usr/syno/etc/rc.d/S97apache-sys.sh start
> /usr/syno/etc/rc.d/S95sshd.sh start
@dmarcelino
dmarcelino / compact_timezone_list.html
Last active February 10, 2017 17:49
Python script to generate compact list of timezones (HTML and json)
<select>
<option utc_offset="-11:00" dst="0" value="Etc/GMT+11">UTC-11:00 Pago Pago, Niue</option>
<option utc_offset="-10:00" dst="0" value="Etc/GMT+10">UTC-10:00 HST, Rarotonga, Tahiti, Honolulu</option>
<option utc_offset="-10:00" dst="1" value="America/Adak">UTC-10:00 Adak</option>
<option utc_offset="-09:30" dst="0" value="Pacific/Marquesas">UTC-09:30 Marquesas</option>
<option utc_offset="-09:00" dst="1" value="America/Anchorage">UTC-09:00 Anchorage, Juneau, Metlakatla, Nome, Sitka, Yakutat</option>
<option utc_offset="-09:00" dst="0" value="Etc/GMT+9">UTC-09:00 Gambier</option>
<option utc_offset="-08:00" dst="0" value="Etc/GMT+8">UTC-08:00 Pitcairn</option>
<option utc_offset="-08:00" dst="1" value="PST8PDT">UTC-08:00 PST8PDT, Dawson, Vancouver, Whitehorse, Tijuana, Los Angeles</option>
<option utc_offset="-07:00" dst="1" value="MST7MDT">UTC-07:00 MST7MDT, Cambridge Bay, Edmonton, Inuvik, Yellowknife, Chihuahua, Mazatlan, Ojinaga, Boise, Denver</option>
@dmarcelino
dmarcelino / stress.sh
Last active April 27, 2017 05:00
Raspberry Overclock stability test
#!/bin/bash
# Simple stress test for system. If it survives this, it's probably stable.
# Free software, GPL2+
# Based on http://elinux.org/RPiconfig#Overclocking
# but using 'cat' instead of 'yes' since OpenELEC for Raspberry doesn't have yes
CORES=1
NO_READS=1
NO_WRITES=3
@dmarcelino
dmarcelino / fix-wordpress-permissions.sh
Created January 13, 2018 17:53 — forked from Adirael/fix-wordpress-permissions.sh
Fix wordpress file permissions
#!/bin/bash
#
# This script configures WordPress file permissions based on recommendations
# from http://codex.wordpress.org/Hardening_WordPress#File_permissions
#
# Author: Michael Conigliaro <mike [at] conigliaro [dot] org>
#
WP_OWNER=www-data # <-- wordpress owner
WP_GROUP=www-data # <-- wordpress group
WP_ROOT=$1 # <-- wordpress root directory
let child = require("child_process")
let source_map = require("source-map")
let SourceMapConsumer = source_map.SourceMapConsumer
let path = require("path")
var crypto = require('crypto');
module.exports = function(source, sourceMap) {
this.cacheable()
this.async()
var self = this
@dmarcelino
dmarcelino / bs4_display.js
Last active March 9, 2018 21:57
Simple util library to show/hide HTML elements using the new BS4 classes d-none/d-*-none and d-block/d-*-block.
(function(window){
'use strict';
// wrapper
function bs4Display() {
var _bs4Display = {};
_bs4Display.DUMMY_PREFIX = 'dummy'
// private methods
@dmarcelino
dmarcelino / clip
Created December 1, 2019 17:19 — forked from elwinar/clip
Shortcut to pipe from and to clipboard using xclip
#!/bin/bash
# Linux version
# Use this script to pipe in/out of the clipboard
#
# Usage: someapp | clip # Pipe someapp's output into clipboard
# clip | someapp # Pipe clipboard's content into someapp
#
if command -v xclip 1>/dev/null; then
if [[ -p /dev/stdin ]] ; then