Skip to content

Instantly share code, notes, and snippets.

View bnlambert's full-sized avatar

Boyong Lambert bnlambert

View GitHub Profile
@martinburch
martinburch / demo.py
Last active March 2, 2022 08:56
Python MySQL upsert
#!/usr/bin/env python
# encoding: utf-8
import MySQLdb
from upsert import upsert
db = MySQLdb.connect(host="localhost", user="root", passwd="", db="demo", charset="utf8")
c = db.cursor()
import warnings
warnings.filterwarnings("ignore", "Unknown table.*")
@yajra
yajra / axios-401-response-interceptor.js
Last active September 20, 2023 06:24
Axios 401 response interceptor.
// Add a 401 response interceptor
window.axios.interceptors.response.use(function (response) {
return response;
}, function (error) {
if (401 === error.response.status) {
swal({
title: "Session Expired",
text: "Your session has expired. Would you like to be redirected to the login page?",
type: "warning",
showCancelButton: true,
@MoOx
MoOx / isDblTouchTap.js
Last active April 30, 2023 19:28
Double touch tap workaround for React based on onTouchTap (react-tap-event-plugin)
const dblTouchTapMaxDelay = 300
let latestTouchTap = {
time: 0,
target: null,
}
export default function isDblTouchTap(event) {
const touchTap = {
time: new Date().getTime(),
target: event.currentTarget,
@danharper
danharper / CatchAllOptionsRequestsProvider.php
Last active April 20, 2024 01:53
Lumen with CORS and OPTIONS requests
<?php namespace App\Providers;
use Illuminate\Support\ServiceProvider;
/**
* If the incoming request is an OPTIONS request
* we will register a handler for the requested route
*/
class CatchAllOptionsRequestsProvider extends ServiceProvider {
@staltz
staltz / introrx.md
Last active May 24, 2024 07:56
The introduction to Reactive Programming you've been missing
@tfhartmann
tfhartmann / sns.py
Created February 12, 2014 14:00
Example script on how to publish a message to an AWS SNS Queue
#!//opt/boxen/homebrew/bin/python
import boto.sns
import json
REGION = 'us-west-2'
TOPIC = '<ARN>'
URL = '<Body of Message in this example I used a url>'
@iancoleman
iancoleman / txjson.py
Last active November 17, 2020 19:55
Decimal numbers in python json dump
# In response to https://bitcointalk.org/index.php?topic=56424.msg1454348#msg1454348
# Highlights that json encoding of floats is no good
# and that decimals can be used for encoding.
import json
from decimal import Decimal as D
d1 = D(11) / D(10) # 1.1
d2 = D(22) / D(10) # 2.2
@m-manu
m-manu / parse_csv_file.php
Last active April 24, 2024 17:33
Useful CSV Parser for PHP 5.2
<?php
/*
Copyright (c) 2013, Manu Manjunath
All rights reserved.
Redistribution and use of this program in source/binary forms, with or without modification are permitted.
Link to this gist is preferred, but not a condition for redistribution/use.
*/
function parse_csv_file($csvfile) {
@iros
iros / API.md
Created August 22, 2012 14:42
Documenting your REST API

Title

<Additional information about your API call. Try to use verbs that match both request type (fetching vs modifying) and plurality (one vs multiple).>

  • URL

    <The URL Structure (path only, no root url)>

  • Method: