Skip to content

Instantly share code, notes, and snippets.

View adamkleingit's full-sized avatar

Adam Klein adamkleingit

View GitHub Profile
const renderGridRowCell = (colConfig, row, index) => {
const CustomValue = colConfig.component;
const value = CustomValue ? <CustomValue data={ row }/> : row[colConfig.field];
return <td key={ index }>{ value }</td>;
};
@adamkleingit
adamkleingit / mockup.md
Last active January 27, 2022 11:30
Timer App

Timer App

Please create an app for managing timed tasks.

  1. The user can input a text and click Add
  2. A new task is added with the title, and 00:00 time, and a play button.
  3. Clicking Play will play this task: the timer will start running, and the icon will change to a pause icon. Also - any other running task will be paused.
  4. Clicking Pause will pause the task.
  5. The total time is always updated.
@adamkleingit
adamkleingit / chaining.js
Last active September 28, 2015 08:34
example of using defer
function getAllUsers() {
let promise = $http.get('/settings')
.then((settings) => {
if(settings.defaultUsers) {
return getDefaultUsers();
}
else {
// get some more data
return $http.get('/users')
.then((users) => {
@adamkleingit
adamkleingit / DashboardCtrl.js
Created August 20, 2015 14:55
Example of changing URL without refreshing the view
function DashboardCtrl(DashboardFilter, pubsub) {
var self = this;
function init() {
// Bindable filter, updates automatically
self.filter = DashboardFilter.getFilter();
// Listen to filter change:
pubsub.on(DASHBOARD_FILTER_CHANGE, function(oldFilter, newFilter) {
// Example handling of filter change:
if (oldFilter.dashboardName != newFilter.dashboardName) {
self.initPanes();
@adamkleingit
adamkleingit / hover to expand input.css
Last active August 29, 2015 14:22
hover to expand input
input {
overflow:hidden;
width:32px;
height:30px;
border-color:grey;
transition:width 0.4s linear, border-color 0.4s linear;
&.hover {
width:236px;
}
}
@adamkleingit
adamkleingit / gist:0a08c18d77cf5e8e0e01
Created November 26, 2014 09:12
Closures for Angular controllers
var MyCtrl = (function () {
var myDependency;
function MyCtrl(_myDependency_){
myDependency = _myDependency_;
}
MyCtrl.prototype.myFunction = function () {
return myDependency.aFunction();
}
return MyCtrl;
})()
@adamkleingit
adamkleingit / lesson_7.md
Last active January 4, 2016 16:39
Lesson 7 homework
  • Project cleanup
    • Remove users new, create, edit, update, destroy actions and relevant links
    • Add link to edit_user_registration_path from the user's email
    • Make sure has_many :cats uses dependent destroy
  • destroy
    • Don't allow destroying the last user in the DB
    • Don't allow destroying female cats
    • Use can_edit? to show / hide destroy link for cat
  • many to many
  • Add validation on like model - user can't like a cat twice
@adamkleingit
adamkleingit / bardelas_homework_6.md
Last active January 4, 2016 06:19
Hackademy Bardelas Homework lesson #6
  • devise and authentication:
    • Change after_sign_in path
    • Change some devise config
    • Change devise forgot password email's content
  • associations:
    • Play with other dependents
    • Name the user's association 'owner' (comment out the original one so you can revert)
    • Name the cat's association 'owned_cats' (comment out the original one so you can revert)
  • authorization:
  • restrict users from editing / updating other users
@adamkleingit
adamkleingit / homework.md
Last active January 3, 2016 19:59
Homework for lesson #5

Homework:

  • implement the missing stuff from presentation:
    • flash messages
    • before filters
    • simple_form
  • Create a cat model:
    • name (string) - required
    • bio (text) - optional
  • gender (string) - Male or Female
@adamkleingit
adamkleingit / user.rb
Last active December 20, 2015 08:08
500Tech / Rails Riddles #2
# Improve / Fix as many things in the code below
# Answers should be sent to hackademy@500tech.com
# Good luck
class User < ActiveRecord::Base
validates_presence_of :name, :email, :date_of_birth, :age_category
before_save do
age = (Time.now - date_of_birth).year
if age < 10 age_category = 'child'