Skip to content

Instantly share code, notes, and snippets.

import Effects
import Effect.File
import Effect.StdIO
import Control.IOExcept
readFile : Eff (FileOpResult (List String)) [FILE R]
readFile = readAcc [] where
readAcc : List String -> Eff (FileOpResult (List String)) [FILE R]
readAcc acc = if (not !eof)
then do
data Format = Number Format
| Str Format
| Lit Char Format
| End
%name Format fmt
PrintfType : Format -> Type
PrintfType (Number fmt) = Int -> PrintfType fmt
PrintfType (Str fmt) = String -> PrintfType fmt
@abdulsattar
abdulsattar / install.md
Last active July 29, 2016 09:38
Phoenix Installation
brew update && brew install elixir
mix local.hex
mix archive.install https://github.com/phoenixframework/archives/raw/master/phoenix_new.ez

Install Postgresql (if not installed already):

brew install postgresql
@abdulsattar
abdulsattar / diarium-fail.erl
Created December 28, 2015 18:05
Failure in Diarium
3:00:49.409 [error] GenServer #PID<0.266.0> terminating
** (stop) exited in: GenServer.call(#PID<0.265.0>, {:checkout, :run}, 5000)
** (EXIT) an exception was raised:
** (UndefinedFunctionError) undefined function: Connection.start_link/2 (module Connection is not available)
Connection.start_link(Postgrex.Connection, [hostname: "localhost", timeout: 5000, otp_app: :diarium, repo: Diarium.Repo, adapter: Ecto.Adapters.Postgres, username: "postgres", password: "postgres", database: "diarium_prod", extensions: [{Ecto.Adapters.Postgres.DateTime, []}, {Postgrex.Extensions.JSON, [library: Poison]}], port: 5432])
(ecto) lib/ecto/adapters/connection.ex:27: Ecto.Adapters.Connection.connect/2
(ecto) lib/ecto/pools/poolboy/worker.ex:58: Ecto.Pools.Poolboy.Worker.handle_call/3
(stdlib) gen_server.erl:629: :gen_server.try_handle_call/4
(stdlib) gen_server.erl:661: :gen_server.handle_msg/5
(stdlib) proc_lib.erl:240: :proc_lib.init_p_do_apply
@abdulsattar
abdulsattar / timezone.rb
Created September 30, 2014 08:43
Rails overrides
module ElfTimeZone
extend ActiveSupport::Concern
included do
def timezone
Time.zone_for(self)
end
def self.inherited(child)
child.columns.select{|c| c.type == :datetime}.each do |c|
@abdulsattar
abdulsattar / tasks.md
Created September 19, 2014 09:07
Tasks
  1. Print all the command line parameters
  2. Write a calculator that asks for number 1, number 2 and then an operand +,-,*,/
  3. Write a multiplication table to a file
  4. Read a comma separated value file and print each of its columns and rows
  5. Create a class Contact and read it's values from a CSV file
  6. Write a Contact object to the file. Then append its value to the file.
  7. Ability to edit a contact
  8. Ability to delete a contact.

Keybase proof

I hereby claim:

  • I am abdulsattar on github.
  • I am abdulsattar (https://keybase.io/abdulsattar) on keybase.
  • I have a public key whose fingerprint is 1C47 C754 0E53 16B6 1E2B 2D14 0809 9006 45E8 4429

To claim this, I am signing this object:

@abdulsattar
abdulsattar / version
Created September 1, 2014 05:50
Complete VIM version
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jan 2 2014 19:39:47)
Included patches: 1-52
Modified by pkg-vim-maintainers@lists.alioth.debian.org
Compiled by buildd@
Huge version with GTK2-GNOME GUI. Features included (+) or not (-):
+acl +farsi +mouse_netterm +syntax
+arabic +file_in_path +mouse_sgr +tag_binary
+autocmd +find_in_path -mouse_sysmouse +tag_old_static
+balloon_eval +float +mouse_urxvt -tag_any_white
+browse +folding +mouse_xterm +tcl

Javascript event handler task

We decided to give you a small practice assignment about javascript event handlers. You need to create a very simple task manager:

  1. A list of tasks should be displayed.
  2. Every task should have a checkbox.
  3. The text of the task should be displayed in an input textbox.
  4. When you check the textbox, it must change the strike the task out. (See text-decoration: strike-through css property).
  5. When you click enter in a textbox, it must create a new task beneath the task currently being edited.
  6. When you press Ctrl+Enter, it must mark that task as completed. (Similar to checking the checkbox)
  7. When you press Ctrl+Backspace, delete the task.
@abdulsattar
abdulsattar / timelogger.md
Last active August 29, 2015 13:56
Timelogger

Develop a timelogger. It should allow you to record time spent doing a task and give you a summary of all the tasks you did on a given day/week.

Here's how it will work, you say timelogger <taskname>. <taskname> is the task you just did. You should store the current timestamp and the <taskname>. So, the time you spent on <taskname> is the difference between times of <taskname> and previous task. You won't count the amount of time for the very first task.

E.g.

$ timelogger arrived
$ timelogger coffee
$ timelogger school_one