Skip to content

Instantly share code, notes, and snippets.

View mahayash315's full-sized avatar

Masayuki Hayashi mahayash315

View GitHub Profile
@gabeweaver
gabeweaver / react-cognito-auth-js.js
Last active December 18, 2024 13:33
React + Cognito User Pools + Cognito Identity JS Example
/*
This example was built using standard create-react-app out of the box with no modifications or ejections
to the underlying scripts.
In this example, i'm using Google as a social provider configured within the Cognito User Pool.
Each step also represents a file, so you can see how I've chosen to organize stuff...you can do it however
you'd like so long as you follow the basic flow (which may or may not be the official way....but its what I found that works.
The docs are pretty horrible)
@ksasao
ksasao / Program.cs
Last active June 10, 2022 19:04
Windows 10 組み込みのOCRを利用するサンプル。UWP の Windows.Media.Ocr が OCR に関するクラス。
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.Graphics.Imaging;
using Windows.Media.Ocr;
using Windows.Storage.Streams;
@alexbonhomme
alexbonhomme / update_username.sh
Created July 20, 2017 10:26
Update Github username in local repos
# Update and convert old HTTPS sources
find . -path "*/.git/config" -exec sed -i '' -e "s,url = https://github.com/blckshrk,url = [email protected]:alexbonhomme,g" {} \;
# Update SSH sources
find . -path "*/.git/config" -exec sed -i '' -e "s,url = [email protected]:blckshrk,url = [email protected]:alexbonhomme,g" {} \;
# checks
find . -path "*/.git/config" -print0 | xargs -0 grep 'alexbonhomme'
@mitechie
mitechie / juju-db
Created March 2, 2017 15:02
juju-db connection script
#!/bin/sh
# Usage: juju-db
# Connect to the database holding the state of the current Juju controller.
set -e
while [ $# -ge 1 ]; do
key="$1"
case $key in
@CrandellWS
CrandellWS / circle.yml
Last active January 4, 2018 03:35 — forked from dazza5000/circle.yml
CircleCI Android Configuration Template - circle.yml
#
# Build configuration for Circle CI
#
general:
artifacts:
- /home/ubuntu/AndroidApp/app/build/outputs/apk/
machine:
environment:
@alexmiragall
alexmiragall / NestedScrollWebView.java
Last active March 1, 2024 01:45
NestedWebView compatible with CoordinatorLayout
package com.tuenti.nestedwebscrollview;
import android.content.Context;
import android.support.v4.view.MotionEventCompat;
import android.support.v4.view.NestedScrollingChild;
import android.support.v4.view.NestedScrollingChildHelper;
import android.support.v4.view.NestedScrollingParent;
import android.support.v4.view.VelocityTrackerCompat;
import android.support.v4.view.ViewCompat;
import android.support.v4.widget.ScrollerCompat;
@gbaman
gbaman / HowToOTG.md
Last active February 25, 2025 03:20
Simple guide for setting up OTG modes on the Raspberry Pi Zero

Raspberry Pi Zero OTG Mode

Simple guide for setting up OTG modes on the Raspberry Pi Zero - By Andrew Mulholland (gbaman).

The Raspberry Pi Zero (and model A and A+) support USB On The Go, given the processor is connected directly to the USB port, unlike on the B, B+ or Pi 2 B, which goes via a USB hub.
Because of this, if setup to, the Pi can act as a USB slave instead, providing virtual serial (a terminal), virtual ethernet, virtual mass storage device (pendrive) or even other virtual devices like HID, MIDI, or act as a virtual webcam!
It is important to note that, although the model A and A+ can support being a USB slave, they are missing the ID pin (is tied to ground internally) so are unable to dynamically switch between USB master/slave mode. As such, they default to USB master mode. There is no easy way to change this right now.
It is also important to note, that a USB to UART serial adapter is not needed for any of these guides, as may be documented elsewhere across the int

@niedbalski
niedbalski / mongo.sh
Created February 10, 2015 20:20
Connect to Juju Mongodb
$ juju ssh 0
machine-0# sudo apt-get install mongodb-clients
machine-0# mongo --ssl -u admin -p $(grep oldpassword /var/lib/juju/agents/machine-0/agent.conf | awk -e '{print $2}') localhost:37017/admin
MongoDB shell version: 2.4.9
connecting to: localhost:37017/admin
juju:PRIMARY> db = db.getSiblingDB("juju")
juju
@supinf
supinf / s3-invalidation.js
Last active January 7, 2023 08:57
AWS Lambda script:: CloudFront Invalidations which are triggered by s3 events.
console.log('Loading event');
var Q = require('q');
var aws = require('aws-sdk');
var cloudfront = new aws.CloudFront();
exports.handler = function (event, context) {
//_log('Received event: ', event);
var bucket = event.Records[0].s3.bucket.name;
@ssinss
ssinss / EndlessRecyclerOnScrollListener.java
Last active January 19, 2024 08:52
Endless RecyclerView OnScrollListener
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
public abstract class EndlessRecyclerOnScrollListener extends RecyclerView.OnScrollListener {
public static String TAG = EndlessRecyclerOnScrollListener.class.getSimpleName();
private int previousTotal = 0; // The total number of items in the dataset after the last load
private boolean loading = true; // True if we are still waiting for the last set of data to load.
private int visibleThreshold = 5; // The minimum amount of items to have below your current scroll position before loading more.
int firstVisibleItem, visibleItemCount, totalItemCount;