Skip to content

Instantly share code, notes, and snippets.

View mukolweke's full-sized avatar
🎯
Its about learning and sharing

Michael O. Mukolwe mukolweke

🎯
Its about learning and sharing
View GitHub Profile
@benwells
benwells / reduce-example.js
Created May 12, 2016 13:40
Using Array.reduce to sum a property in an array of objects
var accounts = [
{ name: 'James Brown', msgCount: 123 },
{ name: 'Stevie Wonder', msgCount: 22 },
{ name: 'Sly Stone', msgCount: 16 },
{ name: 'Otis Redding', msgCount: 300 } // Otis has the most messages
];
// get sum of msgCount prop across all objects in array
var msgTotal = accounts.reduce(function(prev, cur) {
return prev + cur.msgCount;
@mukolweke
mukolweke / login.rb
Created October 17, 2015 09:46
Ruby Login with TK
require 'tk'
class LogIn
def initialize
ph ={'padx'=>50,'pady'=>30}
p=proc{hello}
@text =TkVariable.new
root=TkRoot.new{title "Hello, Name"}
top=TkFrame.new(root)
@mukolweke
mukolweke / mike.rb
Last active October 17, 2015 09:44
Ruby
answer = "kuku"
tries = 0
while tries <3
print("What's my nickname? ")
response=gets
response=response.chomp
tries += 1
if response == "kuku"
puts "That's right!!!"
exit