Skip to content

Instantly share code, notes, and snippets.

View msukmanowsky's full-sized avatar
🥳
Building the future of how companies work with elvex!

Mike Sukmanowsky msukmanowsky

🥳
Building the future of how companies work with elvex!
View GitHub Profile
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 July 22, 2019 20:58
Guess a delimiter being used to split a string using term frequencies of non-word characters.
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.
const express = require('express');
const { filesUpload } = require('./middleware');
app = express();
app.post('/upload', filesUpload, function(req, res) {
// will contain all text fields
req.body
@msukmanowsky
msukmanowsky / cloud-function-firebase-auth.js
Last active March 14, 2019 16:25
Small Express middleware snippet for Cloud Functions to determine if a user is authenticated via Firebase Auth.
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];
}
{
"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 (
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
#!/usr/bin/env python
'''Build up a set of URLs using the common crawl index. See
http://commoncrawl.org/2015/04/announcing-the-common-crawl-index/ for more info.
'''
from __future__ import print_function
import gzip
import logging
import os
import random
@msukmanowsky
msukmanowsky / AspectRatio.java
Last active May 11, 2018 12:38
A little Python script and a Java Pig UDF showing how to produce aspect ratios for any arbitrary screen resolution.
package com.parsely.pig.screens;
import java.io.IOException;
import org.apache.pig.EvalFunc;
import org.apache.pig.data.Tuple;
/**
* This UDF takes a tuple with two positive ints specified 0 -> width
* and 1 -> height and returns the aspect ratio for the resolution.
<!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>

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: