;;Recursively print the elements of a list
(defun print-list (elements)
(cond
((null elements) '()) ;; Base case: There are no elements that have yet to be printed. Don't do anything and return a null list.
(t
;; Recursive case
;; Print the next elem...
Find div with id="article" and strip out all the inner script tags.
#!/usr/bin/env stack
-- stack --resolver lts-7.1 --install-ghc runghc --package text --package lens --package taggy-lens --package string-class --package classy-prelude
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE O...
After enabling and creating migrations there might be a need to initially fill or migrate data in your database. There are several possibilities but for simple migrations you can use the method 'Seed()' in the file Configuration created after calling enable-migrations.
The Seed() function retrieves...
Find f(n): nth Fibonacci number. The problem is quite easy when n is relatively small. We can use simple recursion, f(n) = f(n-1) + f(n-2), or we can use dynamic programming approach to avoid the calculation of same function over and over again. But what will you do if the problem says, Given 0 <...
Sometimes we want to use a where query on a a collection of records returned which is not ActiveRecord::Relation.Hence we get the above error as Where clause is know to ActiveRecord and not to Array.
There is a precise solution for this by using Joins.
EXAMPLE:-
Suppose i need to find all user ...
Private Sub Get_Last_Used_Row_Index()
Dim wS As Worksheet
Set wS = ThisWorkbook.Sheets("Sheet1")
Debug.Print LastRow_1(wS)
Debug.Print LastRow_0(wS)
End Sub
You can choose between 2 options,
regarding if you want to know if there is no data in the worksheet :...
The Memory Model is difficult to understand, and difficult to apply. It is useful if you need to reason about the correctness of multi-threaded code, but you do not want to have to do this reasoning for every multi-threaded application that you write.
If you adopt the following principals when wri...
You can save the error if you want to use it in the rescue clause
def divide(x, y)
begin
x/y
rescue => e
puts "There was a %s (%s)" % [e.class, e.message]
puts e.backtrace
end
end
> divide(10, 0)
There was a ZeroDivisionError (divided by 0)
from ...
This document explains how to display your GitHub feeds/timeline on your website.
Example: A live example is available at:
https://newtonjoshua.com
GitHub timeline:
GitHub provides the public timeline for any user in Atom format.
You can view your timeline at:
https://github.com/{{GitHub...
In the following example there are 2 Screens: SettingsScreen and MenuScreen
Using the first button, on the current screen will change your screen to the other screen.
Here is the code:
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.screenmanager import ScreenManager, Scr...
update <SCHEMA_NAME>.<TABLE_NAME_1> AS A
SET <COLUMN_1> = True
FROM <SCHEMA_NAME>.<TABLE_NAME_2> AS B
WHERE
A.<COLUMN_2> = B.<COLUMN_2> AND
A.<COLUMN_3> = B.<COLUMN_3>
sample json to update
{
"student":{"name":"Rahul", "lastname":"sharma"},
"marks":{"maths":"88"}
}
To update the elements value in the json we need to assign the value and update.
try {
// Create a new in...