Skip to content

Instantly share code, notes, and snippets.

View VinothiniBalakrishnan's full-sized avatar

Vinothini Balakrishnan VinothiniBalakrishnan

View GitHub Profile
@stungeye
stungeye / board_game.rb
Created March 16, 2018 21:41
Has Many Through With ActiveAdmin on Rails
# app/models/board_game.rb
class BoardGame < ApplicationRecord
has_many :board_game_categories
has_many :categories, through: :board_game_categories
## This line was added:
accepts_nested_attributes_for :board_game_categories, allow_destroy: true
has_many :board_game_mechanics
@chranderson
chranderson / nvmCommands.js
Last active September 20, 2024 09:06
Useful NVM commands
// check version
node -v || node --version
// list locally installed versions of node
nvm ls
// list remove available versions of node
nvm ls-remote
// install specific version of node
@namnv609
namnv609 / ws-with-apache2-proxy.conf
Last active February 12, 2019 21:13
ActionCable WebSocket with Apache2 proxy
<VirtualHost *:80 *:443>
# Domain
ServerName servername.domain
SSLEngine On
SSLProxyEngine On
# Path to SSL CRT file
SSLCertificateFile /etc/apache2/ssl/apache.crt
# Path to SSL KEY file
SSLCertificateKeyFile /etc/apache2/ssl/apache.key
# This is to enable WS support. Credits: # https://gist.github.com/Bubelbub/0a942a0d51a3d329897d
# THIS WORKS! for running the example 5.0.0.beta1 chat app on a single instance Elastic beanstalk AWS instance
files:
"/etc/nginx/conf.d/websockets.conf" :
content: |
upstream backend {
server unix:///var/run/puma/my_app.sock;
}
// transform cropper dataURI output to a Blob which Dropzone accepts
function dataURItoBlob(dataURI) {
var byteString = atob(dataURI.split(',')[1]);
var ab = new ArrayBuffer(byteString.length);
var ia = new Uint8Array(ab);
for (var i = 0; i < byteString.length; i++) {
ia[i] = byteString.charCodeAt(i);
}
return new Blob([ab], { type: 'image/jpeg' });
}
@deadkarma
deadkarma / gist:1989808
Created March 6, 2012 23:39 — forked from rails/gist:58761
Calculate time_ago_in_words for javascript
var DateHelper = {
// Takes the format of "Jan 15, 2007 15:45:00 GMT" and converts it to a relative time
// Ruby strftime: %b %d, %Y %H:%M:%S GMT
time_ago_in_words_with_parsing: function(from) {
var date = new Date;
date.setTime(Date.parse(from));
return this.time_ago_in_words(date);
},
// Takes a timestamp and converts it to a relative time
// DateHelper.time_ago_in_words(1331079503000)