Skip to content

Instantly share code, notes, and snippets.

View jenikm's full-sized avatar

Eugene Magdel jenikm

View GitHub Profile
@jenikm
jenikm / ScaleServer.cs
Last active August 29, 2015 14:13
Exposes Zebra printer and scale connected via serial port to http port
using System;
using System.IO;
using System.Collections.Generic;
using System.Text;
using System.IO.Ports;
using System.Net;
using System.Net.Sockets;
using System.Diagnostics;
using System.Windows.Forms;
using System.Text.RegularExpressions;
@jenikm
jenikm / designer.html
Created January 20, 2015 17:14
designer
<link rel="import" href="../paper-radio-button/paper-radio-button.html">
<link rel="import" href="../paper-slider/paper-slider.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
width: 100%;
@jenikm
jenikm / json_object_delete_keys.sql
Created November 18, 2015 04:41
Removes key from json object within postgres
CREATE OR REPLACE FUNCTION "json_object_delete_keys"("json" json, VARIADIC "keys_to_delete" TEXT[])
RETURNS json
LANGUAGE sql
IMMUTABLE
STRICT
AS $function$
SELECT COALESCE(
(SELECT ('{' || string_agg(to_json("key") || ':' || "value", ',') || '}')
FROM json_each("json")
WHERE "key" <> ALL ("keys_to_delete")),
@jenikm
jenikm / get_postal_code.js
Last active January 27, 2017 02:51
Google script postal code resolver
function get_postal_code(street, city, state){
var cache_seconds = 60 * 60 * 24 * 365 // cache for 1 year
var address = [street, city, state, "United States"].join(", ")
var cache = CacheService.getScriptCache();
var cached = cache.get(address);
if (cached != null) {
return cached;
}
@jenikm
jenikm / selected_jira_task_grabber.js
Created February 10, 2017 04:45
Grab Selected Jira tasks
[].slice.apply(document.querySelectorAll(".ghx-selected .ghx-key")).map(a => a.innerHTML).filter(a => a.indexOf("ECOM-") != -1).join(" ")
@jenikm
jenikm / polymer_front_end_services.html
Last active May 30, 2017 22:05
polymer-front-end-services
<!-- APP COMPONENT -->
<app>
<dashboard></dashboard>
</app>
<!-- DASHBAORD COMPONENT -->
<template>
<div>[[referral.balance]]</div>
<template is="dom-if" if="is-loading">
Loading...
@jenikm
jenikm / vimrc
Created July 7, 2017 18:10
.vimrc
"call dein#add(Scripts-----------------------------)
if &compatible
set nocompatible " Be iMproved
endif
" Required:
set runtimepath+=~/.vim/dein/repos/github.com/Shougo/dein.vim
" Required:
call dein#begin(expand('~/.vim/dein')) " plugins' root path
@jenikm
jenikm / prepare-commit-msg
Last active June 3, 2021 00:19
Automatically adds branch name on commit
#!/bin/bash
# Put this into: .git/hooks/prepare-commit-msg
# This way you can customize which branches should be skipped when
# prepending commit message.
BRANCHES_TO_SKIP=(master main env/development env/staging env/production);
for b in "${BRANCHES_TO_SKIP[@]}"; do
BRANCHES_TO_SKIP=("${BRANCHES_TO_SKIP[@]}" "$b-slave")
done;
BRANCH_NAME=$(git symbolic-ref --short HEAD | sed 's/heads\///')
@jenikm
jenikm / expose_silent_errors.rb
Created October 16, 2018 23:07
Exposes silent errors
class ::Exception
def new_initialize(*args)
original_initialize(*args)
puts "[custom error message]: #{self.message}"
end
alias original_initialize initialize
alias initialize new_initialize
@jenikm
jenikm / parse_sms_code
Created April 25, 2019 21:20
Parse 2step verification code
#!/usr/bin/env bash
sqlite3 ~/Library/Messages/chat.db "SELECT text FROM message WHERE text LIKE '%code is%' ORDER BY date DESC LIMIT 1;" |
sed -E 's/[^0-9]//g' |
tr -d '\n' |
pbcopy