Skip to content

Instantly share code, notes, and snippets.

View carpeliam's full-sized avatar
👋
say hi!

Liam Morley carpeliam

👋
say hi!
View GitHub Profile
@carpeliam
carpeliam / db.rake
Created April 15, 2011 02:44
dump, load, or clear a mysql database for a rails project
namespace :db do
desc "Clear all tables"
task :clear => :environment do
conn = ActiveRecord::Base.connection
conn.tables.select{|t| t.start_with? ActiveRecord::Base.table_name_prefix }.each do |t|
conn.drop_table t
end
end
desc "Dump database into an SQL file"
import { Writable } from 'stream';
class InMemoryStream extends Writable {
private chunks: Uint8Array[] = [];
private contentPromise: Promise<string>;
constructor() {
super();
this.contentPromise = new Promise((resolve, reject) => {
this.once('finish', () => { resolve(Buffer.concat(this.chunks).toString('utf8')); });
this.once('error', err => { reject(err); });
[core]
editor = /usr/local/bin/vim
hooksPath = /Users/pivotal/workspace/git-hooks-core
[transfer]
fsckobjects = true
[alias]
gst = git
st = status
di = diff
co = checkout

Keybase proof

I hereby claim:

  • I am carpeliam on github.
  • I am carpeliam (https://keybase.io/carpeliam) on keybase.
  • I have a public key ASCaBaC8yV-Z-VIp5vDtbnw64YJ6UYl83SVwk-1gnCaieAo

To claim this, I am signing this object:

@carpeliam
carpeliam / _form.html.erb
Created April 3, 2011 06:42
jQuery template solution for nested forms in rails
<!-- app/views/project_roles/_form.html.erb -->
<div class="projectRole">
<%= form.label :name %>
<%= form.text_field :name %>
<!-- etc etc etc -->
<!-- the JS down below relies on the following two lines being next to each other -->
<%= form.hidden_field '_destroy' unless form.object.new_record? %>
<a href="#" class="removeNestedItem">Delete</a>
const RPSApp = require("../src/RPSApp")
const {NgModule} = require("@angular/core")
const {BrowserModule} = require("@angular/platform-browser")
const {FormsModule} = require("@angular/forms")
const {platformBrowserDynamic} = require("@angular/platform-browser-dynamic")
const { UseCaseFactory } = require("rps")
require('reflect-metadata')
const jsdom = require("jsdom")
@carpeliam
carpeliam / concourse_bg_funz.js
Last active July 6, 2019 22:20
maybe you want to tie your concourse background to your build status to raise awareness of the current status, GUYS THIS IS IMPORTANT
const pipelineContainer = document.getElementById('pipeline-container');
const PipelineState = {
BUILDING: 'BUILDING',
FAILED: 'FAILED',
PASSING: 'PASSING',
};
const PipelineImages = {
BUILDING: 'https://ketstatic.cdn.ket.org/wp_transfer/images/BOBL/BOBL__000708.3555962.848x480.jpg',
@carpeliam
carpeliam / projectmonitor.raptorize.js
Last active April 1, 2019 16:23
Run a raptor across the screen whenever your build is triggered.
(function() {
$.browser = {mozilla: false, webkit: false};
$('<script>').attr('src', 'https://cdn.jsdelivr.net/gh/davesierra/raptorize@master/jquery.raptorize.1.0.js').appendTo('body');
setInterval(function() {
if ($('.pipeline-graph .started').length) {
$(window).raptorize({enterOn: 'timer', delayTime: 0});
}
}, 15000);
}());
function wrapPromiseInTimeout(promise) {
const possibleError = new Error();
return new Promise((resolve, reject) => {
const timeoutID = setTimeout(() => reject(possibleError), 1000);
promise.then(resolve).catch(reject).finally(() => clearTimeout(timeoutID));
});
}
import React from 'react';
import { connect } from 'react-redux';
function fetchIfNecessary(fetchWithProps, hasRequiredProp) {
function mapDispatchToProps(dispatch, props) {
return { fetch: () => dispatch(fetchWithProps(props)) };
}
return (Component) => {
class Fetcher extends React.Component {
componentDidMount() {