Skip to content

Instantly share code, notes, and snippets.

View M1ke's full-sized avatar

Mike Lehan M1ke

View GitHub Profile
@dixitm20
dixitm20 / lambda_function.py
Last active August 17, 2021 15:43
Truncate Dynamodb Tables
import json
import boto3 as boto3
import os
dynamodb = boto3.resource('dynamodb')
def truncate_table(table_name):
table = dynamodb.Table(table_name)
scan_kwargs = {
@Ocramius
Ocramius / psalm-compendium.php
Last active November 9, 2023 07:27
A small compendium of what is possible with `vimeo/psalm` 3.9.x to add some decent type system features to PHP
<?php
// -- types are a compile-time propagated concept
// https://psalm.dev/r/338f74a96c
class TheType
{
/** @var string */
public $foo = 'bar';
}
@GAS85
GAS85 / http2_apache2_ubuntu16.04.md
Last active February 7, 2023 16:17
How to Enable HTTP/2 in Apache 2.4 on Ubuntu 16.04

Requirements

  • A self-managed VPS or dedicated server with Ubuntu 16.04 running Apache 2.4.xx.
  • For Ubuntu 18.04 please read here --> https://gist.github.com/GAS85/8dadbcb3c9a7ecbcb6705530c1252831
  • A registered domain name with working HTTPS (TLS/SSL). HTTP/2 only works alongside HTTPS because most browsers, including Firefox and Chrome, don’t support HTTP/2 in cleartext (non-TLS) mode.
@chisui
chisui / agnoster-nix.zsh-theme
Last active January 11, 2023 01:51
zsh agonoster theme with nix-shell
# vim:ft=zsh ts=2 sw=2 sts=2
#
# agnoster's Theme - https://gist.github.com/3712874
# A Powerline-inspired theme for ZSH
#
# # README
#
# In order for this theme to render correctly, you will need a
# [Powerline-patched font](https://github.com/Lokaltog/powerline-fonts).
# Make sure you have a recent version: the code points that Powerline
@danswick
danswick / index.html
Last active April 24, 2024 20:14
Fit map to polygon bounds with Turf and Mapbox GL JS
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<title></title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.18.0/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.18.0/mapbox-gl.css' rel='stylesheet' />
<script src='https://api.mapbox.com/mapbox.js/plugins/turf/v2.0.2/turf.min.js'></script>
<style>
@bpolaszek
bpolaszek / CleanAssociationsTrait.php
Created September 24, 2015 09:43
Doctrine : Fix ManyToOne relationships when the value in database is 0 instead of NULL
<?php
use Doctrine\ORM\Mapping as ORM;
use Doctrine\ORM\Event\LifecycleEventArgs;
/**
* Trait CleanAssociationsTrait
*
* This trait is intended to fix the Doctrine ManyToOne relationships when the stored value in database is a 0 instead of NULL.
* Sometimes you plug Doctrine on an existing database without foreign key support.
@harikt
harikt / router.php
Last active August 29, 2015 14:24
Aura.Router v2 default route with wildcard question on irc.
<?php
// router instantiation
$router->add('default_route', '/{controller}')
->setWildcard('other')
->addValues(array(
'action' => 'build_your_controller',
));
;
@qazwsxedc121
qazwsxedc121 / index.html
Last active February 2, 2017 12:29
implement of github commit calender graph using d3.js
<!DOCTYPE html>
<head>
<meta charset="utf-8">
</head>
<body>
<svg id="svg" width="800" height="86">
</svg>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script type="text/javascript">
function show_calendar_graph(){
@lttlrck
lttlrck / gist:9628955
Created March 18, 2014 20:34
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
@didats
didats / nationality_dropdown
Created December 28, 2013 01:24
PHP Function for Nationality Dropdown menu
function nationalityDropdown ($name, $id, $selected, $class="form-control") {
$arr = array('Afghan','Albanian','Algerian','American','Andorran','Angolan','Antiguans','Argentinean','Armenian','Australian','Austrian','Azerbaijani','Bahamian','Bahraini','Bangladeshi','Barbadian','Barbudans','Batswana','Belarusian','Belgian','Belizean','Beninese','Bhutanese','Bolivian','Bosnian','Brazilian','British','Bruneian','Bulgarian','Burkinabe','Burmese','Burundian','Cambodian','Cameroonian','Canadian','Cape Verdean','Central African','Chadian','Chilean','Chinese','Colombian','Comoran','Congolese','Costa Rican','Croatian','Cuban','Cypriot','Czech','Danish','Djibouti','Dominican','Dutch','East Timorese','Ecuadorean','Egyptian','Emirian','Equatorial Guinean','Eritrean','Estonian','Ethiopian','Fijian','Filipino','Finnish','French','Gabonese','Gambian','Georgian','German','Ghanaian','Greek','Grenadian','Guatemalan','Guinea-Bissauan','Guinean','Guyanese','Haitian','Herzegovinian','Honduran','Hungarian','Icelander','India