Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Adam Kirkwood adamkirkwood

🏠
Working from home
View GitHub Profile
@dbridges
dbridges / _comment.html.slim
Last active Feb 20, 2021
Stimulus.js and Rails remote forms with error handling
View _comment.html.slim
- # app/views/comments/_comment.html.slim
li data-controller="comment" data-action="click->comment#hello"
= "#{comment.message} by #{comment.user.email}"
@adamkirkwood
adamkirkwood / adamkirkwood.sketchpack
Last active Apr 20, 2017
Favorite Sketch.app Plugins
View adamkirkwood.sketchpack
{
"name": "Adam Kirkwood's SKetchpack",
"schema_version": "0.1.0",
"locked": false,
"plugins": {
"AnimaApp/auto-layout": {
"name": "auto-layout",
"owner": "AnimaApp",
"version": "0.2.3",
"version_range": [
@juliangruber
juliangruber / extend.plist
Last active Aug 23, 2020
Here is how to accept files dropped on an @electronjs app's icon in osx. For this to work you need to properly package the app into a `.app`, and to place the CFBundleDocumentTypes spec into it's Info.plist. Here we're using electron-packager.
View extend.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeName</key>
<string>All Files</string>
<key>LSHandlerRank</key>
@derwiki
derwiki / README.md
Last active Nov 21, 2020
Ruby module that you can use in a `before_action` on sensitive controllers for which you'd like a usage audit trail
View README.md

Adding an audit log to your Rails app

If you have any sort of administrative interface on your web site, you can easily imagine an intruder gaining access and mucking about. How do you know the extent of the damage? Adding an audit log to your app is one quick solution. An audit log should record a few things:

  • controller entry points with parameter values
  • permanent information about the user, like user_id
  • transient information about the user, like IP and user_agent

Using the Rails framework, this is as simple as adding a before_action to your admin controllers. Here’s a basic version that I’m using in production.

@PatrickJS
PatrickJS / factory-shared.es5.js
Last active Apr 19, 2018
Different examples of OOP "class" with "inheritance" done using JavaScript including languages that transpile into js. Take notice to the amount of boilerplate that's needed in ES5 compared to ES6. These examples all have the same interface with pros/cons for each pattern. If they seem similar that's whole point especially the difference between…
View factory-shared.es5.js
var EventEmitter = require('events').EventEmitter;
var _ = require('lodash');
// Factory shared
var makePerson = function() {
var person = {};
EventEmitter.call(person);
person.wallet = 0;
_.extend(person, personMethods)
return person;
@addyosmani
addyosmani / README.md
Last active Apr 18, 2021 — forked from 140bytes/LICENSE.txt
108 byte CSS Layout Debugger
View README.md

CSS Layout Debugger

A tweet-sized debugger for visualizing your CSS layouts. Outlines every DOM element on your page a random (valid) CSS hex color.

One-line version to paste in your DevTools

Use $$ if your browser aliases it:

~ 108 byte version

View commit-emoji.md
  • 🎨 when improving the format/structure of the code
  • 🚀 when improving performance
  • ✏️ when writing docs
  • 💡 new idea
  • 🚧 work in progress
  • when adding feature
  • when removing feature
  • 🔈 when adding logging
  • 🔇 when reducing logging
  • 🐛 when fixing a bug
@tlivings
tlivings / results.md
Last active Dec 30, 2015
Node.js outbound SSL testing
View results.md

Overview

Testing out fedor's SSL enhancements. You don't notice the difference... At first!

Once you adjust ciphers to disable ECDH, then you get the nice surprise.

Test Description

Running an http server that acts as a proxy to an SSL server, all running on localhost.

View shootitlive.load.js
(function(global) {
var silpUrl = '//s3-eu-west-1.amazonaws.com/silp.shootitlive.com/js/silp.min.js';
// Globals
if(!global.Silp) { global.Silp = {}; };
var Silp = global.Silp;
// To keep track of which embeds we have already processed
if(!Silp.foundEls) Silp.foundEls = [];
@dsibilly
dsibilly / gist:2992412
Created Jun 26, 2012
Node.js clustered HTTP server example
View gist:2992412
(function () {
'use strict';
var cluster = require('cluster'),
http = require('http'),
os = require('os'),
/*
* ClusterServer object