Skip to content

Instantly share code, notes, and snippets.

@debloper
debloper / xrandr.sh
Last active February 10, 2024 02:30
Add system unrecognized but monitor supported resolution in X
#!/bin/bash
# Copyright (c) 2021 Soumya Deb <debloper@gmail.com>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
@debloper
debloper / bandwidth.js
Last active November 5, 2023 19:15
Determine client's connection speed with JavaScript
// Let's initialize the primitives
var startTime, endTime, fileSize;
// Set up the AJAX to perform
var xhr = new XMLHttpRequest();
// Rig the call-back... THE important part
xhr.onreadystatechange = function () {
// we only need to know when the request has completed
@debloper
debloper / reset.sh
Created May 2, 2015 12:59
Reset forgotten MySQL root password
service mysql stop
mysqld_safe --skip-grant-tables
mysql --user=root mysql
@debloper
debloper / schema.svg
Created March 25, 2015 10:52
Uniqueness of Singularity
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@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 / snapChrome.html
Created August 9, 2011 15:31
Here's a li'l bit of HTML, CSS & JS - it hangs chrome irrecoverably; can you work out WHY? ;) B)
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>TRex - Let's Back Tweets Up</title>
<style>
body { background: #eee; }
form {
width: 640px; margin: auto; padding: 24px; display: table;
@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 / app.js
Last active October 21, 2022 21:48
A simple WHOIS & Reverse Lookup server written in Node.js. Run `npm install express`, then `node <file>.js` to get the server(s) up
var net = require("net")
, dns = require("dns")
, exp = require("express")
, app = exp();
app.configure(function() {
app.use(exp.logger());
app.use(app.router);
});
@debloper
debloper / 9GAG.js
Last active November 15, 2021 07:35
Unlock NSFW without logging in
// Remap $ to jQuery object
var $ = jQuery;
// The real fun begins... first catch all the post-anchors & loop on them
$(document).on("scroll", function () {
// Let's declare some reusable globals for the next iterations
var urlBase = "http://img-9gag-lol.9cache.com/photo/";
$(".badge-evt.badge-nsfw-entry-cover").each(function () {
// Remove the NSFW class, to avoid redundant processing
@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']);