Skip to content

Instantly share code, notes, and snippets.

@joshnuss
joshnuss / httpStore.js
Last active Oct 9, 2021
A Svelte store backed by HTTP
View httpStore.js
import { writable } from 'svelte/store'
// returns a store with HTTP access functions for get, post, patch, delete
// anytime an HTTP request is made, the store is updated and all subscribers are notified.
export default function(initial) {
// create the underlying store
const store = writable(initial)
// define a request function that will do `fetch` and update store when request finishes
store.request = async (method, url, params=null) => {
@khongi
khongi / .env
Last active Oct 27, 2021
Sonarr + Radarr + Jackett + qBittorrent + ddclient cloudflare DNS update + Traefik reverse proxy with LetsEncrypt on Docker
View .env
QBITTORRENT_PATH=<PATH>
QBITTORRENT_WEBUI_PORT=<PORT>
DOWNLOAD_PATH=<PATH>
MEDIA_PATH=<PATH>
JACKETT_PATH=<PATH>
SONARR_PATH=<PATH>
RADARR_PATH=<PATH>
DOMAIN=<YOUR DOMAIN>
TZ=<Timezone e.g. Europe/Budapest>
USERDIR=<HOME DIR PATH>
@tukkajukka
tukkajukka / 20190417131115_test-setup.ts
Last active Oct 26, 2021
How to use Knex.js in a TypeScript project
View 20190417131115_test-setup.ts
import { Knex } from 'knex'
export async function up(knex: Knex): Promise<any> {
await knex.schema.createTable('test_setup', (table: Knex.TableBuilder) => {
table.integer('foobar');
});
}
export async function down(knex: Knex): Promise<any> {
await knex.schema.dropTable('test_setup');
@jsidhu
jsidhu / ansible_ssl_cert.yaml
Created Mar 15, 2017
Ansible snippet to create a self signed ssl certificate
View ansible_ssl_cert.yaml
# - name: Generate DH Params (may take several minutes!)
# command: openssl dhparam \
# -out "/data/jenkins_home/ssl/dhparam.pem" 2048
# args:
# creates: "/data/jenkins_home/ssl/dhparam.pem"
#
# - name: Generate ECC Key
# command: openssl ecparam \
# -genkey \
# -name prime256v1 \
@fulv
fulv / main.yml
Last active Aug 2, 2021
Ansible - Creating users and copying ssh keypair files to the remote server
View main.yml
Put this in your `local-configure.yml` file, add as many users as you need:
users:
- name: fulvio
sudoer: yes
auth_key: ssh-rsa blahblahblahsomekey this is actually the public key in cleartext
- name: plone_buildout
group: plone_group
sudoer: no
auth_key: ssh-rsa blahblahblah ansible-generated on default
@mvaneijgen
mvaneijgen / Scale resolution.scpt
Last active Apr 5, 2020
Change screen resolution AppleScript
View Scale resolution.scpt
local index1, index2
set index1 to 3 -- 1920 x 1200
set index2 to 4 -- 1280 x 800
-- Launch "System Preferences", open the "Displays" options and change to the "Display" tab
tell application "System Preferences"
activate
set the current pane to pane id "com.apple.preference.displays"
reveal anchor "displaysDisplayTab" of pane id "com.apple.preference.displays"
@alexandregz
alexandregz / .profile
Last active May 27, 2016
to add to .profile (ash shell used with Synology NAS)
View .profile
# place to git, ipkg, another shell commands
PATH=/volume1/@optware/bin:$PATH
export PATH
# more useful prompt shell
#PS1="`hostname`> "
PS1='\u@\h:\w'
case `id -u` in
0) PS1="${PS1}# ";;
@fpirsch
fpirsch / toHaveClass.js
Created Sep 30, 2014
Protractor/jasmine toHaveClass custom matcher
View toHaveClass.js
/**
* Custom "toHaveClass" matcher.
*
* Based on https://gist.github.com/darthwade/9305669
* and https://gist.github.com/elgalu/94284ec0ac3e8a590507
*
* usage :
* require('./toHaveClass.js');
* ...
* expect($('html')).toHaveClass('wf-active');
View chai_custom_matcher.js
/*
Chai - Add CustomMatchers
usage:
var CustomMatchers = require('./support/friendly_news_path_matcher');
chai.use(CustomMatchers);
expect('/materia/FooBar').to.be.a.friendlyNewsPath();
*/
@jeffjohnson9046
jeffjohnson9046 / title-case-filter.js
Created Mar 26, 2014
A title-case filter for AngularJs
View title-case-filter.js
// Came from the comments here: https://gist.github.com/maruf-nc/5625869
app.filter('titlecase', function() {
return function (input) {
var smallWords = /^(a|an|and|as|at|but|by|en|for|if|in|nor|of|on|or|per|the|to|vs?\.?|via)$/i;
input = input.toLowerCase();
return input.replace(/[A-Za-z0-9\u00C0-\u00FF]+[^\s-]*/g, function(match, index, title) {
if (index > 0 && index + match.length !== title.length &&
match.search(smallWords) > -1 && title.charAt(index - 2) !== ":" &&
(title.charAt(index + match.length) !== '-' || title.charAt(index - 1) === '-') &&