Skip to content

Instantly share code, notes, and snippets.

View KevinTCoughlin's full-sized avatar

Kevin T. Coughlin KevinTCoughlin

View GitHub Profile
var input = [
'billowy',
'biopsy',
'chinos',
'defaced',
'chintz',
'sponged',
'bijoux',
'abhors',
'fiddle',
@KevinTCoughlin
KevinTCoughlin / print-multiplication-table.js
Created October 20, 2015 03:21
JavaScript print multiplication table NxN
function printMultiplicationTable(n) {
for (var i = 1; i < n; i++) {
var str = '';
for (var k = 1; k < n; k++) {
str += i * k + '\t';
}
console.log(str);
}
}
var chars = 'OISZLJT';
// Generates a string of tetris pieces of n-length
function tetris(n) {
var pieces = chars.split('');
return _.map(_.times(n, function() {
var piece = _.sample(pieces);
pieces = _.without(pieces, piece);
if (pieces.length <= 0) {
pieces = chars.split('');
  • Example 1: Write a function to reverse a string.
    // Question #1
    public static String reverse(final String s) {
        final char[] chars = s.toCharArray();
        final int pivot = chars.length / 2;
        for (int i = 0; i < pivot; i++) {
            final int pos = chars.length - i - 1;
            final char c = chars[i];
            final char d = chars[pos];
@KevinTCoughlin
KevinTCoughlin / .eslintrc.js
Last active September 21, 2015 14:32 — forked from nkbt/.eslintrc.js
Strict ESLint config for React, ES6 (based on Airbnb Code style)
{
"env": {
"browser": true,
"node": true,
"es6": true
},
"plugins": ["react"],
"ecmaFeatures": {
@KevinTCoughlin
KevinTCoughlin / what-forces-layout.md
Last active September 19, 2015 22:21 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout. This is also called reflow or layout thrashing, and is common performance bottleneck.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()
@KevinTCoughlin
KevinTCoughlin / MainActivity.java
Last active September 8, 2015 15:46
Debugging Bookends data set insertion
package com.kevintcoughlin.bookendsadaptertest;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
@KevinTCoughlin
KevinTCoughlin / themes-debug.xml
Last active September 8, 2015 12:01 — forked from dlew/themes-debug.xml
With the new theming in AppCompat, a lot of assets are tinted automatically for you via theme attributes. That has often led me to wonder "where the hell did this color come from?" You can replace your normal theme with this debug theme to help figure out the source of that color.
<!-- You can change the parent around to whatever you normally use -->
<style name="DebugColors" parent="Theme.AppCompat">
<!-- System colors -->
<item name="android:windowBackground">@color/__debugWindowBackground</item>
<item name="android:colorPressedHighlight">#FF4400</item>
<item name="android:colorLongPressedHighlight">#FF0044</item>
<item name="android:colorFocusedHighlight">#44FF00</item>
<item name="android:colorActivatedHighlight">#00FF44</item>
@KevinTCoughlin
KevinTCoughlin / 4-27-15-challenge-212.js
Created June 15, 2015 03:22
Solution for /r/dailyprogrammer's [2015-04-27] Challenge #212 [Easy] Rövarspråket
var input = ['Jag talar Rövarspråket!', 'I\'m speaking Robber\'s language!'];
function rovarsprakify(str) {
var result = [];
for (var c of str) {
var newChar = (isVowel(c) || !isAlpha(c)) ? c : c + 'o' + c.toLowerCase();
result.push(newChar);
}
return result.join('');
}
@KevinTCoughlin
KevinTCoughlin / tumblr_post_by_blog.js
Last active August 29, 2015 14:22
Example tumblr.js get post by blog name and id
var tumblr = require('tumblr.js');
var client = tumblr.createClient({ consumer_key: /* your consumer key */ });
client.posts('annetje-stichting', { id: 119348740950 }, function (err, data) {
console.log(data);
/**
* Example output:
* ...
* note_count: 0,
* caption: '<h2>helping kids in tough times</h2><p>lorem ipsumlorem ipsumlorem ips