Skip to content

Instantly share code, notes, and snippets.

@nodesocket
nodesocket / Angular Cliffnotes.md
Last active June 15, 2020 01:39
Angular.js Cliffnotes

Modules

var app = angular.module('app', []);

Using modules in views

 <html ng-app="app"></html>
@dwayne
dwayne / _vertical-center.scss
Last active August 29, 2015 14:02 — forked from denzildoyle/Vertical Center.css
Vertically center anything.
// Assumes Bourbon - See http://bourbon.io/docs/#transform
// To see it in action, check out http://codepen.io/dwayne/pen/gjDGx
@mixin vertical-center {
position: relative;
top: 50%;
@include transform(translateY(-50%));
}
@mprajwala
mprajwala / import_csv_to_mongo
Last active July 23, 2023 20:07
Store CSV data into mongodb using python pandas
#!/usr/bin/env python
import sys
import pandas as pd
import pymongo
import json
def import_content(filepath):
mng_client = pymongo.MongoClient('localhost', 27017)
class GroupersController < ApplicationController::Base
def create
@grouper = Grouper.new(leader: current_member)
if @grouper.save
ConfirmedGrouperEmails.new(@grouper).deliver
AssignBarForGrouper.enqueue(@grouper.id)
redirect_to home_path
else
class GroupersController < ApplicationController::Base
def create
@grouper = Grouper.new(leader: current_member)
if @grouper.save
confirm_grouper_via_emails(@grouper)
enqueue_bar_assignment(@grouper)
redirect_to home_path
else
@dwayne
dwayne / exact-center.scss
Created February 19, 2014 11:48
A mixin for horizontally and vertically centering a block element.
// http://css-tricks.com/snippets/css/exactly-center-an-imagediv-horizontally-and-vertically/
@mixin exact-center($width, $height) {
width: $width;
height: $height;
position: absolute;
left: 50%;
top: 50%;
margin-left: -$width / 2;
margin-top: -$height / 2;
}
@dwayne
dwayne / 01-intro.md
Last active September 5, 2024 13:47
My notes from the book "ng-book: The Complete Book on AngularJS by Ari Lerner".

Introduction

Author: Ari Lerner.

AngularJS offers a single framework that can be used to build dynamic, client-centric applications. It provides:

  • Module support
  • DOM manipulation
  • Animations
  • Templating
@insin
insin / contactform.js
Last active June 21, 2025 08:07
React contact form example
/** @jsx React.DOM */
var STATES = [
'AL', 'AK', 'AS', 'AZ', 'AR', 'CA', 'CO', 'CT', 'DE', 'DC', 'FL', 'GA', 'HI',
'ID', 'IL', 'IN', 'IA', 'KS', 'KY', 'LA', 'ME', 'MD', 'MA', 'MI', 'MN', 'MS',
'MO', 'MT', 'NE', 'NV', 'NH', 'NJ', 'NM', 'NY', 'NC', 'ND', 'OH', 'OK', 'OR',
'PA', 'RI', 'SC', 'SD', 'TN', 'TX', 'UT', 'VT', 'VA', 'WA', 'WV', 'WI', 'WY'
]
var Example = React.createClass({
@robskrob
robskrob / gist:8364397
Created January 10, 2014 23:04
controller_users
class UsersController < ApplicationController
before_action :set_user, only: [:show, :edit, :update]
before_action :require_same_user, only: [:edit, :update]
def index
@user = User.all
end
def show
@robskrob
robskrob / gist:8364382
Created January 10, 2014 23:03
form_for_private_message
<div class='well'>
<%= form_for @private_message, url: private_messages_user_path(@user) do |f| %>
<div class="control-group">
<%= f.label :receiver_uid %>
</div>
<div class="control-group">
<%= f.label :subject %>
<%= f.text_field :subject %>
</div>
<div class="control-group">