Skip to content

Instantly share code, notes, and snippets.

View remino's full-sized avatar

Rem remino

View GitHub Profile
@tkgwy
tkgwy / serve-python2.py
Last active October 12, 2024 02:27
SimpleHTTPServer for SPA
import os
import sys
import urlparse
import SimpleHTTPServer
import BaseHTTPServer
class Handler(SimpleHTTPServer.SimpleHTTPRequestHandler):
def do_GET(self):
url = urlparse.urlparse(self.path)
@eruffaldi
eruffaldi / gettoken.sh
Created September 25, 2018 09:23
Google OAuth 2.0 full example bash script.
#!/bin/bash
#1) on https://console.developers.google.com/ register project and associate API from library
# OUTPUT: client_id,client_secret
client_id="..."
client_secret="...."
#2) get authorization code at the following link using web browser
# OUTPUT: code
scope="https://www.googleapis.com/auth/drive"
@melastmohican
melastmohican / rtf2md.sh
Created March 22, 2017 23:34
Convert RTF to Markdown on Mac OSX with textutl and pandoc
textutil -convert html -stdout file.rtf | pandoc --from=html --to=markdown --out=file.md
@LindaLawton
LindaLawton / GoogleAuthenticationCurl.sh
Last active June 9, 2024 10:41
Curl bash script for getting a Google Oauth2 Access token
# Tutorial https://www.daimto.com/how-to-get-a-google-access-token-with-curl/
# YouTube video https://youtu.be/hBC_tVJIx5w
# Client id from Google Developer console
# Client Secret from Google Developer console
# Scope this is a space seprated list of the scopes of access you are requesting.
# Authorization link. Place this in a browser and copy the code that is returned after you accept the scopes.
https://accounts.google.com/o/oauth2/auth?client_id=[Application Client Id]&redirect_uri=http://127.0.0.1&scope=[Scopes]&response_type=code
# Exchange Authorization code for an access token and a refresh token.
@kndt84
kndt84 / authorize.js
Last active May 17, 2024 03:11
Sample code: how to refresh session of Cognito User Pools with Node.js and Express
const AWS = require('aws-sdk');
const CognitoUserPool = require('amazon-cognito-identity-js-node').CognitoUserPool;
const CognitoUserSession = require('amazon-cognito-identity-js-node').CognitoUserSession;
const CognitoUser = require('amazon-cognito-identity-js-node').CognitoUser;
const CognitoIdToken = require('amazon-cognito-identity-js-node').CognitoIdToken;
const CognitoAccessToken = require('amazon-cognito-identity-js-node').CognitoAccessToken;
const CognitoRefreshToken = require('amazon-cognito-identity-js-node').CognitoRefreshToken;
const cfg = require('config').config;
const COGNITO_IDENTITY_POOL_ID = cfg.COGNITO_IDENTITY_POOL_ID;
@remino
remino / dig.rb
Last active August 29, 2015 14:23 — forked from re5et/dig.rb
class Hash
def dig(*path)
path.inject(self) do |location, key|
location.is_a?(Hash) ? location[key] : nil
end
end
end
@code0100fun
code0100fun / tests_acceptance_foo-test.js
Last active July 9, 2018 01:05
Ember CLI QUnit text content helpers
// tests/acceptance/foo-test.js
// Assert that text should be found
assert.hasText('Not Found'); // Error: Could not find text "Not Found" on the page
// Provide custom message
assert.hasText('Not Found', 'Expected to find "Not Found"'); // Error: Expected to find "Not Found"
// Find any number of elements containing the query text
text('Found'); // [<div>Found</div>, <input value="Found">]
@tim-evans
tim-evans / simple-format.js
Created April 16, 2015 14:46
Simple format helper
import Ember from "ember";
const AUTO_EMAIL_RE = /([\w.!#\$%+-]+@[\w-]+(?:\.[\w-]+)+)/;
const AUTO_LINK_CRE = [/<[^>]+$/, /^[^>]*>/];
const AUTO_LINK_RE = /(?:((?:ed2k|ftp|http|https|irc|mailto|news|gopher|nntp|telnet|webcal|xmpp|callto|feed|svn|urn|aim|rsync|tag|ssh|sftp|rtsp|afs|file):)\/\/|(www\.))([^\s<]+)/;
var autoLink = function (text, context) {
var buffer = [];
if (context.autoLink) {
#!/bin/sh
# /share/CE_CACHEDEV1_DATA/.qpkg/autorun/autorun-plexconnect.sh
#
# mkdir /share/CE_CACHEDEV1_DATA/.qpkg/autorun
# chmod +x /share/CE_CACHEDEV1_DATA/.qpkg/autorun/autorun-plexconnect.sh
curl -Lk https://gist.githubusercontent.com/plasticine/86e189c42ac8ec7598a8/raw/update_plex_connect.sh | bash &
@samhemelryk
samhemelryk / pre-commit
Last active May 27, 2021 05:41
A git pre-commit hook example.
#!/bin/bash
#
# This pre-commit hook checks that you havn't left and DONOTCOMMIT tokens in
# your code when you go to commit.
#
# To use this script copy it to .git/hooks/pre-commit and make it executable.
#
# This is provided just as an example of how to use a pre-commit hook to
# catch nasties in your code.