Skip to content

Instantly share code, notes, and snippets.

@hamzamu
hamzamu / examples.md
Created April 26, 2020 11:09 — forked from ErisDS/examples.md
Ghost Filter Query examples

Filter Queries - Example Use Cases

Here are a few example use cases, these use cases combine filter with other parameters to make useful API queries. The syntax for any of this may change between now, implementation, and release - they're meant as illustrative examples :)

Fetch 3 posts with tags which match 'photo' or 'video' and aren't the post with id 5.

api.posts.browse({filter: "tags:[photo, video] + id:-5", limit="3"});

GET /api/posts?filter=tags%3A%5Bphoto%2Cvideo%5D%2Bid%3A-5&limit=3

@hamzamu
hamzamu / addvhost.sh
Created April 22, 2020 22:37 — forked from runbrun/addvhost.sh
bash script to create nginx virtual hosts
#!/usr/bin/env bash
#
# Nginx - new server block
# http://rosehosting.com
read -p "Enter username : " username
read -p "Enter domain name : " domain
# Functions
ok() { echo -e '\e[32m'$domain'\e[m'; } # Green
die() { echo -e '\e[1;31m'$domain'\e[m'; exit 1; }
@hamzamu
hamzamu / stream_to_youtube.sh
Created March 23, 2020 11:14 — forked from olasd/stream_to_youtube.sh
Stream video to youtube via ffmpeg
#! /bin/bash
#
# Diffusion youtube avec ffmpeg
# Configurer youtube avec une résolution 720p. La vidéo n'est pas scalée.
VBR="2500k" # Bitrate de la vidéo en sortie
FPS="30" # FPS de la vidéo en sortie
QUAL="medium" # Preset de qualité FFMPEG
YOUTUBE_URL="rtmp://a.rtmp.youtube.com/live2" # URL de base RTMP youtube
@hamzamu
hamzamu / .block
Created March 19, 2020 11:18 — forked from mbostock/.block
Swiss Cantons
license: gpl-3.0
@hamzamu
hamzamu / countryblock.sh
Created March 18, 2020 08:44 — forked from mombrea/countryblock.sh
Block a list of IP ranges using IPSet and IPTables
#!/bin/bash
#Script to process ip ranges to ban using IPSet and IPTables
ipset create countryblock hash:net
while read line; do ipset add countryblock $line; done < blocklist.txt
iptables -I INPUT -m set --match-set countryblock src -j DROP
http://feeds.reuters.com/news/artsculture
http://feeds.reuters.com/reuters/businessNews
http://feeds.reuters.com/reuters/companyNews
http://feeds.reuters.com/reuters/entertainment
http://feeds.reuters.com/reuters/environment
http://feeds.reuters.com/reuters/healthNews
http://feeds.reuters.com/reuters/lifestyle
http://feeds.reuters.com/news/reutersmedia
http://feeds.reuters.com/news/wealth
http://feeds.reuters.com/reuters/MostRead
@hamzamu
hamzamu / slugify.js
Created January 25, 2020 09:15 — forked from codeguy/slugify.js
Create slug from string in Javascript
function string_to_slug (str) {
str = str.replace(/^\s+|\s+$/g, ''); // trim
str = str.toLowerCase();
// remove accents, swap ñ for n, etc
var from = "àáäâèéëêìíïîòóöôùúüûñç·/_,:;";
var to = "aaaaeeeeiiiioooouuuunc------";
for (var i=0, l=from.length ; i<l ; i++) {
str = str.replace(new RegExp(from.charAt(i), 'g'), to.charAt(i));
}
@hamzamu
hamzamu / slugify.js
Created January 25, 2020 09:15 — forked from codeguy/slugify.js
Create slug from string in Javascript
function string_to_slug (str) {
str = str.replace(/^\s+|\s+$/g, ''); // trim
str = str.toLowerCase();
// remove accents, swap ñ for n, etc
var from = "àáäâèéëêìíïîòóöôùúüûñç·/_,:;";
var to = "aaaaeeeeiiiioooouuuunc------";
for (var i=0, l=from.length ; i<l ; i++) {
str = str.replace(new RegExp(from.charAt(i), 'g'), to.charAt(i));
}
@hamzamu
hamzamu / vign1.red
Created January 3, 2020 12:36 — forked from kermitaner/vign1.red
vigenere encrypting with gui
Red [needs: 'view]
CRLF: copy "^M^/" ;; constant for 0D 0A line feed
;;------------------------------------
crypt: func ["function to en- or decrypt message from textarea tx1"
/decrypt "decrypting switch/refinement" ][
;;------------------------------------
;; when decrypting we have to remove the superflous newlines
;; and undo the base64 encoding first ...
@hamzamu
hamzamu / project-create.sh
Created May 5, 2019 16:49 — forked from francoisromain/project-create.sh
A bash script to create a Git post-receive hook to deploy after a Git push
#!/bin/bash
# Call this file with `bash ./project-create.sh project-name [service-name]`
# - project-name is mandatory
# - service-name is optional
# This will creates 4 directories and a git `post-receive` hook.
# The 4 directories are:
# - $GIT: a git repo
# - $TMP: a temporary directory for deployment