Skip to content

Instantly share code, notes, and snippets.

@debloper
debloper / probe.php
Last active April 17, 2023 03:06
Update/reset mediawiki password for a user directly in SQLite DB without SUDO (NFSN/nearlyfreespeech.net edge case)
<?php
// Replace <DB> with actual DB name
$db = new PDO("sqlite:/path/to/<DB>.sqlite") or die("cannot open the database");
// The WHERE clause excludes internal users; feel free to filter it any way you want
$query = $db->query("SELECT * FROM user WHERE user_email <> '';");
// Get the column names; unfortunately this is the simplest way
$meta = "";
for ($i=0; $i<=7; $i++) { $meta = $meta . "\n" . $query->getColumnMeta($i)["name"]; }
@debloper
debloper / crop.sh
Last active August 3, 2023 02:25
FFmpeg Scripts
# Generic syntax
ffmpeg -i in.mp4 -filter:v "crop=outW:outH:cropX:cropY" -c:a copy out.mp4
# Center-crop an HD video from UHD video
ffmpeg -i in.mp4 -filter:v "crop=1920:1080:960:540" -c:a copy out.mp4
@debloper
debloper / script.sh
Last active May 18, 2020 21:03
Initialize a simple cassandra cluster
$ cqlsh
Connected to Test Cluster at 127.0.0.1:9042.
[cqlsh 5.0.1 | Cassandra 3.11.6 | CQL spec 3.4.4 | Native protocol v4]
Use HELP for help.
cqlsh> CREATE KEYSPACE foo WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
cqlsh> USE foo;
cqlsh:foo> CREATE TABLE foo.bar (id int PRIMARY KEY, status text, details list<text>);
cqlsh:foo> INSERT INTO bar (id, status, details) VALUES (1, 'done', ['sample text']);
@debloper
debloper / README.md
Created February 14, 2020 17:13
Create commits and send pull requests on GitHub from CLI with cURL

Prerequisites

  • Personal Access <token> for <user> with all repo[...] access (may need more permissions, depending on the commit)
  • The <user> having write/push access to the existing <branch> of the intended <repo> of <org|user>
  • For creating new commits
    • The base64 encoded file content <base64content> is required.
    • To update an existing file, the <sha> hash of the file that's being replaced on GitHub repo is required

Creating Commits

Creating commits with /contents endpoint come with a limitation (as of APIv3) that it can only create/update a file. Updating multiple files (with a DIFF) doesn't seem to be possible very easily. The SHA sum is only required to update a single file with new contents, not for creating new file.

@debloper
debloper / index.html
Created October 23, 2019 02:01 — forked from JulesBlm/index.html
GeologicalTimescale
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<meta http-equiv="Content-Language" content="en" />
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no, width=device-width">
<title>Geologic Time</title>
<link rel="stylesheet" href="timescale.css" />
@debloper
debloper / docker-compose.yml
Created October 9, 2019 20:35
Run a ghost blog container with mounted data directory (./content) from the host
version: '3'
services:
ghost:
image: ghost:latest
restart: always
ports:
- 8080:2368
volumes:
@debloper
debloper / homepage.md
Last active April 21, 2018 14:15
Get Started with Fabric8 Planner
  • Head over to Fabric8 Planner Repo on GitHub
  • Fork the repo, then clone the repo locally and switch to gh-pages branch
  • Use any static file-server (for e.g. python SimpleHTTPServer or npm http-server) to serve the content
  • Open the URL in your favorite modern browser (usually http://localhost:8080 or http://localhost:3000)
  • You should see the landing page like http://fabric8-ui.github.io/fabric8-planner/

  • If everything is good till now, then you're ready to make changes to the source
  • Maintain good commitiquettes to add new changes, and push them to your fork
@debloper
debloper / docker-compose.yml
Last active October 4, 2017 13:29
Fabric8 Planner Stack
version: '3'
services:
planner:
build: .
container_name: fabric8-planner-runtime
image: fabric8-planner-runtime
# command: npm run test:unit
environment:
FABRIC8_WIT_API_URL: http://localhost:8080/api/
@debloper
debloper / readme.md
Last active August 9, 2018 21:21
URL scheme customization for a Ghost blog

Quick steps to change URL scheme in a self-deployed Ghose blog:

  • Open DB in CLI: # sqlite3 content/data/ghost.db
  • Set the UX properties (optional): sqlite> .headers ON & sqlite> .mode column
  • Check the settings table (look for key "permalinks"): sqlite> SELECT * FROM settings;
  • Change the URL scheme: sqlite> update settings set value = '/:id/' where key = 'permalinks';
  • Quit database (sqlite> .quit) & restart ghost server

N.B: year, month, day, slug, id etc are valid keywords for configuring the URL (let me know if I've missed any).
Statutory Warning: if you're using different database, the steps are similar, but the commands will differ to achieve the same purpose. Also, I'm not to be blamed if you broke your thing while trying this out.

@debloper
debloper / benderSays.rs
Created May 17, 2015 08:22
A simple switch-case/match with string output reference implementation on Rust
use std::os;
fn main() {
let argv = &os::args();
match argv[1] {
~"biteMe" => println("\n\tBite my _Rusty_ metal ass!\n"),
~"killYa" => println("\n\tKILL ALL HUMANS!\n"),
~"letsGo" => println("\n\tLet's GO ALREADYYY...\n"),
_ => println("\n\tOh. Your. God.\n")
}
}