Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@lustremedia
lustremedia / simple-vue-apollo-subscription.vue
Created May 26, 2020 15:24 — forked from gorbypark/simple-vue-apollo-subscription.vue
A simple vue-apollo subscription example
<!--
This is a simple vue single file component example of using a subscription with vue-apollo.
This starts out as a query, and then if there are any changes to the underlying data,
the subscription updates it. The subscription works by holding open a websocket connection
to the GraphQL server. This was tested using Hasura.io and PostgreSQL, but should work with
any GraphQL implementation that supports websocket subscriptions. In the example, the
PostgreSQL table would be in a schema named "myschema" and a table named
"mytable" and that table would have two columns, "id" and "name".
-->
@lustremedia
lustremedia / unob_spiegelplus.user.js
Created February 7, 2018 09:51 — forked from trent2/unob_spiegelplus.user.js
Unobfuscate SPIEGEL plus articles with greasemonkey
// ==UserScript==
// @name unobfuscate spiegel plus
// @namespace obfuscate
// @include http://www.spiegel.de/*
// @version 1
// @grant none
// ==/UserScript==
if(document.getElementsByClassName('obfuscated-content')[0] != undefined) {
document.getElementsByClassName('obfuscated-content')[0].setAttribute("class", "");
var elems = document.getElementsByClassName('obfuscated'), t, or, c, i, cc;
@lustremedia
lustremedia / wordpress-change-domain-migration.sql
Created October 9, 2017 07:43 — forked from chuckreynolds/wordpress-change-domain-migration.sql
Use this SQL script when changing domains on a WordPress site. Whether you’re moving from an old domain to a new domain or you’re changing from a development domain to a production domain this will work. __STEP1: always backup your database. __STEP2: change the ‘oldsite.com’ and ‘newsite.com’ variables to your own. __STEP3: make sure your databa…
SET @oldsite='http://oldsite.com';
SET @newsite='http://newsite.com';
UPDATE wp_options SET option_value = replace(option_value, @oldsite, @newsite) WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET post_content = replace(post_content, @oldsite, @newsite);
UPDATE wp_links SET link_url = replace(link_url, @oldsite, @newsite);
UPDATE wp_postmeta SET meta_value = replace(meta_value, @oldsite, @newsite);
/* only uncomment next line if you want all your current posts to post to RSS again as new */
#UPDATE wp_posts SET guid = replace(guid, @oldsite, @newsite);
Copied from https://www.pantz.org/software/mysql/mysqlcommands.html
This is a list of handy MySQL commands that I use time and time again. At the bottom are statements, clauses, and functions you can use in MySQL. Below that are PHP and Perl API functions you can use to interface with MySQL. To use those you will need to build PHP with MySQL functionality. To use MySQL with Perl you will need to use the Perl modules DBI and DBD::mysql.
Below when you see # it means from the unix shell. When you see mysql> it means from a MySQL prompt after logging into MySQL.
To login (from unix shell) use -h only if needed.
# [mysql dir]/bin/mysql -h hostname -u root -p
Create a database on the sql server.
// iMacro CheatSheet - Command Reference
// http://wiki.imacros.net/Command_Reference
// iMacros supports 3 types of variables:
// * The macro variables !VAR0 thru !VAR9. They can be used with the SET and ADD command inside a macro.
// * Built-in variables. They contain certain values set by iMacros.
// * User-defined variables. They are defined in-macro using the SET command.
function feedFilter($query) {
if ($query->is_feed) {
add_filter('rss2_item', 'feedContentFilter');
}
return $query;
}
add_filter('pre_get_posts','feedFilter');
function feedContentFilter($item) {
#!/bin/bash
# installs plenv, perl, carton, cpanminus, sets up environment in .bash_profile
# from https://github.com/tokuhirom/plenv#readme
PLENV_PERL_VERSION='5.18.1'
if [[ -n "$PERL_MB_OPT" ]]; then
echo "You must unset your local::lib environment variables first"
# Author: Pieter Noordhuis
# Description: Simple demo to showcase Redis PubSub with EventMachine
#
# Update 7 Oct 2010:
# - This example does *not* appear to work with Chrome >=6.0. Apparently,
# the WebSocket protocol implementation in the cramp gem does not work
# well with Chrome's (newer) WebSocket implementation.
#
# Requirements:
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby
#!/usr/local/bin/perl
use strict;
use warnings;
my $pi = 3.1415;
my $focDist = 700; #e.g. 10000mm = 1m Focus Distance
my $cropFactor = 1.6;
my $focLen = 24*1.6; #e.g. 50mm
my $actualFocLen = $focLen * $cropFactor;
my $fstop = 2.8; # 1, 1.4 , 2 , 2.8, 4, 5.6
// Handle previous/next navigation
$(function() {
// Requires jQuery 1.7+ to utilize the new "on" event attachment
$("#contentPadding").on("click", "a.prev, a.next", function (event) {
$.pjax({
"url": $(this).attr("href"),
"fragment": "#contentPadding",
"container": "#contentPadding",
"complete": function(data) {
// Update the className on the BODY tag