SQLite Maker
SQLite Maker is a small utility that makes the creation of SQLite databases simpler and more fun. Create a database, its tables and columns using your fingertips. You can then […]
SQLite Maker is a small utility that makes the creation of SQLite databases simpler and more fun. Create a database, its tables and columns using your fingertips. You can then […]
Please follow the steps below; 1. Open your mac’s security and privacy settings. Open Settings -> Security and privacy setting. 2. Under the General tab, click on (Anywhere) under (Allow […]
Just in case you never heard of OpenStruct…
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
require 'ostruct' module Application class Config < OpenStruct end class << self def config @config ||= Config.new end def configure yield config end end end |
And this is how it can be implemented…
1 2 3 4 5 6 7 8 9 10 11 12 13 |
Application.configure do |c| c.name = "Abu Lewis" c.single = false c.number_of_children = 3 c.email = "foo@bar.com" end puts Application.config.name puts Application.config.single puts Application.config.number_of_children puts Application.config.email |
I love that i found it :). Check it at ice_cube github repo. This is my first playing around code;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
require 'ice_cube' # "Yearly in February on the 7th day of the month on Mondays" rule = IceCube::Rule.yearly.month_of_year(:february).day_of_month(7).day(:monday) # Create a new Schedule object schedule = IceCube::Schedule.new # Load the schedule with the rule above schedule.add_recurrence_rule(rule) # Print the dates in which the rule above occures, starting from today untill 30 years in the future puts schedule.occurrences_between(Date.today, Date.today >> 12*30) |
The output would look like this
1 2 3 4 5 6 |
2022-02-07 12:56:03 +0100 2028-02-07 12:56:03 +0100 2033-02-07 12:56:03 +0100 2039-02-07 12:56:03 +0100 |
To be short and concise, As soon as you have identified a behavior that is or may be shared between different objects, at that time it is a good idea […]
To simplify things, lets fabricate a use case scenario; Imagine that you have to control a password’s strength when the user is registering a new account. The controlling of the […]
To demonstrate, I have written a server that has one task. It reads a word and sends it back to the client in a reversed form. The server code in […]
After writing a server socket in ruby, I had to find out a solution to monitor its process in any way. I knew that there is a gem for that […]
To be able to write in Assyrian on Mac’s OS X system. You will need to download: 1. A keyboard layout (click to download) 2. The fonts (click to download) […]
To demonstrate execution of concurrent Objective-C code, I wrote this simple example below. The two functions you have to read about to understand the code are; dispatch_get_global_queue and dispatch_async.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
#import <Foundation/Foundation.h> int main(int argc, const char * argv[]) { @autoreleasepool { // 1. Get the handle of the system's predefined global concurrent queue, DISPATCH_QUEUE_PRIORITY_DEFAULT. dispatch_queue_t dispatchQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); // 2. Enqueue the code to be run asynchronously, to the queue above. dispatch_async(dispatchQueue, ^{ for(int i = 1; i <= 10; i++) { usleep(1000000); NSLog(@"Inside the dispatch async: %d", i); } }); // 3. Lets run the same code on the main thread just to see what will happen. for(int i = 1; i <= 10; i++) { usleep(1000000); NSLog(@"Outside the dispatch async: %d", i); } return 0; } } |
[…]