Skip to content

Instantly share code, notes, and snippets.

Mike Sukmanowsky msukmanowsky

Block or report user

Report or block msukmanowsky

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View use-async-storage.js
import { useState, useEffect } from "react";
import { AsyncStorage } from "react-native";
function useAsyncStorage(key, initialValue) {
const [storedValue, setStoredValue] = useState(initialValue);
useEffect(() => {
AsyncStorage.getItem(key)
.then(value => {
if (value === null) return initialValue;
View fileinput_usage.py
import fileinput
for line in fileinput.input():
print(line)
"""
Usages
- Read from stdin: cat somefile | python script.py
- read from multiple files: python script.py file1.txt file2.txt file3.txt
@msukmanowsky
msukmanowsky / guess_string_separator.py
Last active Jul 22, 2019
Guess a delimiter being used to split a string using term frequencies of non-word characters.
View guess_string_separator.py
import re
from collections import Counter
def guess_string_separator(
string: str,
to_ignore: Iterable[str] = tuple(),
ignore_empty_strings: bool = True,
) -> Optional[str]:
"""Guess a delimiter being used to split a string using term frequencies.
View usage.js
const express = require('express');
const { filesUpload } = require('./middleware');
app = express();
app.post('/upload', filesUpload, function(req, res) {
// will contain all text fields
req.body
View cloud-functions-busboy-file-upload.js
// middleware.js
exports.filesUpload = function(req, res, next) {
// See https://cloud.google.com/functions/docs/writing/http#multipart_data
const busboy = new Busboy({
headers: req.headers,
limits: {
// Cloud functions impose this restriction anyway
fileSize: 10 * 1024 * 1024,
}
@msukmanowsky
msukmanowsky / cloud-function-firebase-auth.js
Last active Mar 14, 2019
Small Express middleware snippet for Cloud Functions to determine if a user is authenticated via Firebase Auth.
View cloud-function-firebase-auth.js
const admin = require('firebase-admin');
function getIdToken(req) {
const authHeader = req.header('Authorization') || '';
const parts = authHeader.split('Bearer ');
if (parts.length === 1) return null;
return parts[1];
}
View frontapp.error.json
{
"error": {
"message": "You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.",
"stack": "Error: You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.\n at Object.h [as getState] (https://app.frontapp.com/v2/main.1374c0dee4fbfedf4ec9.js?1374c0dee4fbfedf4ec9:48:82825)\n at B (<anonymous>:1:28201)\n at <anonymous>:1:37657\n at Object.g [as dispatch] (https://app.frontapp.com/v2/main.1374c0dee4fbfedf4ec9.js?1374c0dee4fbfedf4ec9:48:84062)\n at dispatch (<anonymous>:1:40300)\n at https://app.frontapp.com/v2/main.1374c0dee4fbfedf4ec9.js?1374c0dee4fbfedf4ec9:186:5025\n at Object.dispatch (https://app.frontapp.com/v2/main.1374c0dee4fbfedf4ec9.js?1374c0dee4fbfedf4ec9:170:15439)\n at dispatch (
View output.log
2018-08-17 13:01:07 WARN NativeCodeLoader:62 - Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
2018-08-17 13:01:07 INFO SparkContext:54 - Running Spark version 2.3.1
2018-08-17 13:01:07 INFO SparkContext:54 - Submitted application: pandas_udf
2018-08-17 13:01:07 INFO SecurityManager:54 - Changing view acls to: mikesukmanowsky
2018-08-17 13:01:07 INFO SecurityManager:54 - Changing modify acls to: mikesukmanowsky
2018-08-17 13:01:07 INFO SecurityManager:54 - Changing view acls groups to:
2018-08-17 13:01:07 INFO SecurityManager:54 - Changing modify acls groups to:
2018-08-17 13:01:07 INFO SecurityManager:54 - SecurityManager: authentication disabled; ui acls disabled; users with view permissions: Set(mikesukmanowsky); groups with view permissions: Set(); users with modify permissions: Set(mikesukmanowsky); groups with modify permissions: Set()
2018-08-17 13:01:08 INFO Utils:54 - Successfully started service 'sparkDriver' on port 51078.
2018-08-1
View authSample.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>AuthTest</title>
</head>
<body>
<button id="sign_in_button">Sign in</button>
View keybase.md

Keybase proof

I hereby claim:

  • I am msukmanowsky on github.
  • I am msukmanowsky (https://keybase.io/msukmanowsky) on keybase.
  • I have a public key ASDR9dQAC8XMWg0DhKSTdYP4NYjCoWN1qXLDbrRoI08HGQo

To claim this, I am signing this object:

You can’t perform that action at this time.