Skip to content

Instantly share code, notes, and snippets.

View ahaverty's full-sized avatar

Alan ahaverty

View GitHub Profile
@CodyFitzpatrick
CodyFitzpatrick / seeds_with_sql_import.rb
Last active November 14, 2022 11:17
Ruby on Rails - Import Data via SQL in seeds.rb
# Creation of other records in Ruby above ...
connection = ActiveRecord::Base.connection
sql = File.read('db/import.sql') # Change path and filename as necessary
statements = sql.split(/;$/)
statements.pop
ActiveRecord::Base.transaction do
statements.each do |statement|
@keyboardr
keyboardr / FirebaseLiveData.java
Created November 19, 2017 10:41
A LiveData sourced from Firebase Realtime Database
import android.arch.lifecycle.LiveData;
import android.support.annotation.NonNull;
import android.util.Log;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.GenericTypeIndicator;
import com.google.firebase.database.ValueEventListener;
@DevStrefa
DevStrefa / counties.html
Created May 19, 2017 10:23
select counties of ireland
<select name="county">
<option value="antrim">Antrim</option>
<option value="armagh">Armagh</option>
<option value="carlow">Carlow</option>
<option value="cavan">Cavan</option>
<option value="clare">Clare</option>
<option value="cork">Cork</option>
<option value="derry">Derry</option>
<option value="donegal">Donegal</option>
<option value="down">Down</option>
@wbotelhos
wbotelhos / clear-sidekiq-jobs.sh
Last active April 2, 2024 10:04
Clear Sidekiq Jobs
require 'sidekiq/api'
# 1. Clear retry set
Sidekiq::RetrySet.new.clear
# 2. Clear scheduled jobs
Sidekiq::ScheduledSet.new.clear
@daliborgogic
daliborgogic / delay.js
Created December 16, 2016 15:26
Node.js Async/Await delay
'use strict'
const timeout = ms => new Promise(res => setTimeout(res, ms))
function convinceMe (convince) {
let unixTime = Math.round(+new Date() / 1000)
console.log(`Delay ${convince} at ${unixTime}`)
}
async function delay () {
@caldwbr
caldwbr / FirebaseUIHelp.txt
Created September 24, 2016 20:56
Help for Installing FirebaseUI Drop-In Authentication System with Swift 3
*******AppDelegate.swift *******
//
// AppDelegate.swift
// Bizzy Books
//
// Created by Brad Caldwell on 9/23/16.
// Copyright © 2016 Caldwell Contracting LLC. All rights reserved.
//
@cutiko
cutiko / LoginActivity.java
Last active August 29, 2022 14:53
How to customize firebase-ui-auth for Android
public class LoginActivity extends AppCompatActivity {
private static final int RC_SIGN_IN = 343;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
@samtstern
samtstern / FirebaseImageLoader.java
Last active January 7, 2018 22:26
StorageReference + Glide
package com.firebase.ui.storage.images;
import android.util.Log;
import com.bumptech.glide.Priority;
import com.bumptech.glide.load.data.DataFetcher;
import com.bumptech.glide.load.model.stream.StreamModelLoader;
import com.google.android.gms.tasks.Tasks;
import com.google.firebase.storage.StorageReference;
import com.google.firebase.storage.StreamDownloadTask;
@episage
episage / UniqueIdGenerator.ts
Created May 17, 2016 18:44 — forked from mikelehen/generate-pushid.js
JavaScript code for generating Firebase Push IDs
// https://gist.github.com/mikelehen/3596a30bd69384624c11
/**
* Fancy ID generator that creates 20-character string identifiers with the following properties:
*
* 1. They're based on timestamp so that they sort *after* any existing ids.
* 2. They contain 72-bits of random data after the timestamp so that IDs won't collide with other clients' IDs.
* 3. They sort *lexicographically* (so the timestamp is converted to characters that will sort properly).
* 4. They're monotonically increasing. Even if you generate more than one in the same timestamp, the
* latter ones will sort after the former ones. We do this by using the previous random bits
* but "incrementing" them by 1 (only in the case of a timestamp collision).
@cogmission
cogmission / QuickTest.py
Last active July 28, 2016 15:53
Example Use of Raw HTM Algorithms
'''
Created on Feb 8, 2015
@author: David Ray
'''
import numpy as np
from nupic.encoders.scalar import ScalarEncoder as ScalarEncoder
from nupic.algorithms.CLAClassifier import CLAClassifier as CLAClassifier