Skip to content

Instantly share code, notes, and snippets.

@gbrlmza
gbrlmza / slim_catchall_route.php
Created December 28, 2022 00:30 — forked from funkatron/slim_catchall_route.php
Making a "catchall" route in Slim
<?php
/**
* by setting the regex condition for the :method param to '.+', it matches
* everything, including "/" chars. this lets us match any URL of the format.
*
* /api/foo outputs "foo"
* /api/foo/bar/baz outputs "foo/bar/baz"
*/
$app->get('/api/:method', function($method) use ($app) {
echo $method;
@gbrlmza
gbrlmza / slim_catchall_route.php
Created December 28, 2022 00:30 — forked from funkatron/slim_catchall_route.php
Making a "catchall" route in Slim
<?php
/**
* by setting the regex condition for the :method param to '.+', it matches
* everything, including "/" chars. this lets us match any URL of the format.
*
* /api/foo outputs "foo"
* /api/foo/bar/baz outputs "foo/bar/baz"
*/
$app->get('/api/:method', function($method) use ($app) {
echo $method;
@gbrlmza
gbrlmza / utils.js
Last active June 10, 2020 00:17
Google Sheet Script Finance Utils
var cache = CacheService.getScriptCache();
var cacheTTL = 120 * 60 // Cache TTL in seconds
//=========================================================================================================================
// Get MD5 hash
//=========================================================================================================================
function md5(str) {
return Utilities.base64Encode(Utilities.computeDigest(Utilities.DigestAlgorithm.MD5,str));
}
@gbrlmza
gbrlmza / main.go
Last active November 2, 2019 14:21
Mutant DNA detector
package main
import "fmt"
func IsMutant(dna []string) bool {
const minSequenceLength = 4
const requiredSequences = 2
mutantSequences := 0
sequences := make(map[string]string)
@gbrlmza
gbrlmza / read-access.sql
Created August 12, 2018 00:14 — forked from oinopion/read-access.sql
How to create read only user in PostgreSQL
-- Create a group
CREATE ROLE readaccess;
-- Grant access to existing tables
GRANT USAGE ON SCHEMA public TO readaccess;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO readaccess;
-- Grant access to future tables
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO readaccess;
//install dev vesrion of google chrome form https://www.chromium.org/getting-involved/dev-channel
//install chrome-remote-interface from npm npm install chrome-remote-interface
const CDP = require('chrome-remote-interface');
CDP((protocol) => {
const {Page, Runtime} = protocol;
// First, need to enable the domains we're going to use.
Promise.all([
Page.enable(),
@gbrlmza
gbrlmza / android-development.md
Created July 19, 2017 18:29
Android development

Android Courses @ Udacity

Full Curriculum Outline  |  Nanodegree Outlines  |  FAQ / Resources  |  Notes

 

The sections below include all of Udacity's Android-related courses, including their Android Basics & Android Developer Nanodegree material.

The complete course list is presently lacking a linear curriculum, so this reference aims to provide a clear, easy to follow path based on each course's prerequisites. The course order in the "Full Curriculum" sections is structured so that inidividuals with no prior programming experience can work through them from start to finish.

@gbrlmza
gbrlmza / ubuntu-server-setup-16.04-LAMP.md
Created April 15, 2017 21:55 — forked from Otienoh/ubuntu-server-setup-16.04-LAMP.md
LAMP Server setup for Ubuntu 16.04 on Digital Ocean

Server setup for Ubuntu 16.04 on Digital Ocean

The setup installs the following software:

The setup installs the following software:

  • Apache
  • MySQL
  • PHP
  • Node