Skip to content

Instantly share code, notes, and snippets.

View nuc's full-sized avatar
🍱
Always Hungry

Georgios Giannoutsos Barkas nuc

🍱
Always Hungry
View GitHub Profile
@nuc
nuc / gist:fc28090296e0d95108ab19b46f870935
Created October 19, 2016 11:02 — forked from afeld/gist:1254889
YouTube video ID regex
# Parses YouTube URLs directly or from iframe code. Handles:
# * Address bar on YouTube url (ex: http://www.youtube.com/watch?v=ZFqlHhCNBOI)
# * Direct http://youtu.be/ url (ex: http://youtu.be/ZFqlHhCNBOI)
# * Full iframe embed code (ex: <iframe src="http://www.youtube.com/embed/ZFqlHhCNBOI">)
# * Old <object> tag embed code (ex: <object><param name="movie" value="http://www.youtube.com/v/ZFqlHhCNBOI">...)
/(youtu\.be\/|youtube\.com\/(watch\?(.*&)?v=|(embed|v)\/))([^\?&"'>]+)/
$5 #=> the video ID
# test it on Rubular: http://rubular.com/r/eaJeSMkJvo
@nuc
nuc / tabindexDebug.js
Created September 8, 2016 11:14
Debug tabindex with javascript by listening "tab" key event and show in console the active element. Tested in Chrome 25 and Firefox 19
(function(){
"use strict";
document.addEventListener('keydown', function (event) {
setTimeout(function () {
var key, win, frameEl, activeEl, uri, msg;
msg = "";
key = window.event ? event.keyCode : event.which;
//Tab
if (key === 9) {
@nuc
nuc / upload-sourcemap.js
Last active March 27, 2019 06:12
Upload sourcemaps to Sentry
/* eslint-disable no-sync */
const request = require('superagent')
const path = require('path')
const fs = require('fs')
const ACCOUNT = 'account'
const PROJECT = 'project-name'
const TOKEN = 'your-token'
const ASSET_URL = 'https://example.com/assets'
const SOURCEMAPS_PATH = './temp'
@nuc
nuc / plaintext-contenteditable.css
Last active April 18, 2019 01:24 — forked from Schniz/plaintext-contenteditable.css
Plain-Text ContentEditable div for React.js
.comPlainTextContentEditable {
-webkit-user-modify: read-write-plaintext-only;
}
.comPlainTextContentEditable--has-placeholder::before {
content: attr(placeholder);
opacity: 0.5;
color: inherit;
cursor: text;
}
@nuc
nuc / WhyDidYouUpdate.js
Last active December 3, 2017 19:05 — forked from joshma/WhyDidYouUpdateMixin.js
WhyDidYouUpdate Higher Order Component
/* eslint-disable no-console */
import React, { Component } from 'React'
import _ from 'lodash'
/*
* Drop this mixin into a component that wastes
* time according to Perf.getWastedTime() to find
* out what state/props should be preserved. Once it
* says "Update avoidable!" for {state, props},
* you should be able to use shouldComponentUpdate.
@nuc
nuc / xor-checksum-hex.js
Created March 21, 2016 09:02
XOR checksum on array of hex strings
const calculateXORChecksum = array =>
array.reduce((checksum, item) =>
checksum ^ parseInt(item, 16)
, 0).toString(16)

Keybase proof

I hereby claim:

  • I am nuc on github.
  • I am nuc (https://keybase.io/nuc) on keybase.
  • I have a public key whose fingerprint is 85F6 ECCA 1936 DC65 BF91 859B B7AB F0C8 4AC0 1232

To claim this, I am signing this object:

@nuc
nuc / lifx.rb
Created December 14, 2014 19:47
LIFX gem wrapper
require 'rubygems'
require 'lifx'
class Lifx
attr_reader :client, :light
def initialize
@client = LIFX::Client.lan
@client.discover! do |c|
@nuc
nuc / delete-files.js
Created September 24, 2014 08:27
Delete slack files under /files/you
$('#files_list > div > a[data-file-id]').each(function(index, item){TS.files.deleteFile($(item).data('file-id'))})
" Change the color scheme from a list of color scheme names.
" Version 2010-09-12 from http://vim.wikia.com/wiki/VimTip341
" Press key:
" F8 next scheme
" Shift-F8 previous scheme
" Alt-F8 random scheme
" Set the list of color schemes used by the above (default is 'all'):
" :SetColors all (all $VIMRUNTIME/colors/*.vim)
" :SetColors my (names built into script)
" :SetColors blue slate ron (these schemes)