Skip to content

Instantly share code, notes, and snippets.

View letladi's full-sized avatar

Letladi Sebesho letladi

View GitHub Profile
@zlw5009
zlw5009 / blocks_foundations.md
Last active June 27, 2021 06:59
An article on Ruby Blocks and Procs

Building a Foundation with &blocks

What is a Block?

Blocks... What are they anyway? You've probably used them without even realizing it and most certainly have seen them, but do you know what they are?

If we wanted to take a simplistic approach at defining a block we could say:

A block is a chunk of code contained within the do..end or { curly braces } syntax that is to be executed at some point in time.

With that being said, if you've ever used the Enumerable#map or Enumerable#each method, you've probably used a block. Lets take a look at two different types of blocks before we go into more detail about what a block really is.

@letladi
letladi / csvParser.js
Last active August 29, 2015 14:25
Simple Node.js CSV Parser module that returns a collection of objects
var fs = require('fs');
function csvParser(filePath) {
fs.readFile(filePath, 'utf8', function(err, data) {
if (err) {
throw err;
} else {
var result = [];
var lines = data.split('\n');
var headings = lines[0].split(',');
# add the email package
meteor add email
@mebezac
mebezac / application.html.erb
Created February 11, 2014 21:06
Rails Ajax Flash Messages
<div id="main" role="main">
<div class="container">
<div class="row">
<div class="span12" id="top-div"> <!--! added "top-div" id to help with ajax -->
<%= render 'layouts/messages' %>
<%= yield %>
</div>
</div>
<footer>
</footer>
@Whoaa512
Whoaa512 / client_main.js
Last active February 6, 2018 04:49
Meteor code to display user's facebook picture
Meteor.startup(function() {
Template.fb_pic.pic = function() {// helper function to display the pic on the page
var userProfile;
userProfile = Meteor.user().profile;
if(userProfile) { // logic to handle logged out state
return userProfile.picture;
}
};
});