Skip to content

Instantly share code, notes, and snippets.

View t0mdicks0n's full-sized avatar
🎯
Focusing

Tom Dickson t0mdicks0n

🎯
Focusing
View GitHub Profile
@t0mdicks0n
t0mdicks0n / recreate.bash
Created February 6, 2020 13:20
Recreate strange Google App Engine target URL anomaly
#!/bin/bash
git clone https://github.com/GoogleCloudPlatform/python-docs-samples
cd python-docs-samples/appengine/standard/hello_world
# This script requires gcloud being installed and having a current logged in session
gcloud app deploy
@t0mdicks0n
t0mdicks0n / tink_test.md
Last active March 22, 2019 09:00
Small post on how interacting with Tink's excellent API works.

Step 0: Create a developer account at Tink

I was very surprised to find out how easy this was. Cudos to Tink for creating an amazing developer experience!

Step 1: Trigger Tink Link to let user verify Moneypenny as a reader of financial information.

  1. Display the UI
https://oauth.tink.com/0.4/authorize/?client_id=<insert client_id here>&redirect_uri=http://localhost:3000/callback&market=SE&locale=en_US&scope=accounts:read,user:read,credentials:read,transactions:read,investments:read,statistics:read
  1. Get the code in the final url: Code:
@t0mdicks0n
t0mdicks0n / disk_usage.sql
Last active February 28, 2019 09:19
List disk usage of PSQL instance per table in the schema public
SELECT
table_name,
pg_size_pretty(t_size) AS size_pretty
FROM (
SELECT
table_name,
pg_relation_size(quote_ident(table_name)) AS t_size
FROM information_schema.tables
WHERE table_schema = 'public'
UNION ALL
@t0mdicks0n
t0mdicks0n / cmd.c
Created October 19, 2018 15:17
Ghetto implementation in C of native "ls" command in Unix. Compile and run with: gcc -o cmd cmd.c && ./cmd ls
#include <stdio.h>
#include <glob.h>
#include <string.h>
void ls () {
glob_t glob_result;
// Display all files by passing * to glob
glob("*", GLOB_TILDE, NULL, &glob_result);
// Iterate over the files in the current directory
for (unsigned int i = 0; i < glob_result.gl_pathc; ++i) {
@t0mdicks0n
t0mdicks0n / quine.c
Created October 19, 2018 14:46
Run with: `gcc -o quine quine.c && ./quine `
#include <stdio.h>
int main()
{
int c;
// Open the source code as a file buffer
FILE* file = fopen("./quine.c", "r");
if (file) {
// Iterate over the characters in the file
while ((c = getc(file)) != EOF)
@t0mdicks0n
t0mdicks0n / simple_fcm.py
Created October 9, 2018 19:23
A short gist on how to post a push notifications on Android with Python and requests. Much easier to fiddle with this intuitive code when exploring FCM compared to for example Postman.
import requests
import json
body = {
"data":{
"title":"Panprices",
"body":"Go online and shop!",
"url":"https://www.panprices.com"
},
"notification": {
@t0mdicks0n
t0mdicks0n / simple_audit_log.sql
Last active January 18, 2019 10:01
Simple little way to store all INSERTS on a PSQL-database in a form of a audit log. Can be really useful for testing. For production some performance tweaks would have to be made.
-- Create a table for test
CREATE TABLE example_table (
ts timestamp with time zone,
name TEXT,
age INT
);
-- Create a audit table where all queries will be stored
CREATE TABLE example_audit_table (
created_at timestamp default current_timestamp,
@t0mdicks0n
t0mdicks0n / Navbar.jsx
Created June 16, 2018 21:59
Code snippet of an issue occuring after migrating to Material UI V1.
import React from 'react';
import ReactDOM from 'react-dom';
import { Link, withRouter} from 'react-router-dom';
import PropTypes from 'prop-types';
import compose from 'recompose/compose';
// Material UI Imports:
import { withStyles } from '@material-ui/core/styles';
import AppBar from '@material-ui/core/AppBar';
import Toolbar from '@material-ui/core/Toolbar';
import Typography from '@material-ui/core/Typography';
@t0mdicks0n
t0mdicks0n / server.js
Created December 21, 2017 08:40
A small Node Server Application to demonstrate what data get sent to Facebook when the Facebook Pixel is included in a web app.
var express = require('express');
var app = express();
var bodyParser = require('body-parser');
var jsonParser = bodyParser.json();
app.use(bodyParser.json({limit: '50mb'}));
app.enable('trust proxy')
app.get('/thomas', function(req, res) {
requestData = {
@t0mdicks0n
t0mdicks0n / knapsack
Created June 27, 2017 17:55
Knapsack with dynamic programming
var testInput = [
[1, 1],
[3, 4],
[4, 5],
[5, 7]
];
var knapsackOpt = function (arr) {
var matrix = [];
// Loop over the given elements