This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String str1("Llama"); | |
cout << "str1: " << str1[0] << str1[1] << str1[2] << str1[3] << str1[4] << str1[5] << endl; | |
cout << "*str1.begin(): " << *str1.begin() << endl; | |
cout << "*str1.end() == /0: " << (*str1.end() == '\0') << endl; | |
cout << "*++++++++++str1.begin() == /0: " << (*++++++++++str1.begin() == '\0') << endl; | |
cout << "++++++++++str1.begin() != str1.end(): " << ((++++++++++str1.begin()) != str1.end()) << endl; | |
for (String::iterator i = str1.begin(); i != str1.end(); i++) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String str1("Llama"); | |
cout << "str1: " << str1[0] << str1[1] << str1[2] << str1[3] << str1[4] << str1[5] << endl; | |
cout << "*str1.begin(): " << *str1.begin() << endl; | |
cout << "*str1.end() == /0: " << (*str1.end() == '\0') << endl; | |
cout << "*++++++++++str1.begin() == /0: " << (*++++++++++str1.begin() == '\0') << endl; | |
cout << "++++++++++str1.begin() != str1.end(): " << ((++++++++++str1.begin()) != str1.end()) << endl; | |
for (String::iterator i = str1.begin(); i != str1.end(); i++) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
p = [1 -3 2]; | |
r = roots(p); | |
x = linspace(-1, 3); | |
plot(x, polyval(p, x)); | |
hold on; | |
plot(r, zeros(size(r)), "marker", "x", "markersize", 21, "color", "red", "linestyle", "none") | |
hold on; | |
plot(x, zeros(size(x)), '.', 'color', 'red'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
all_nums = Fiber.new do | |
num = 0 | |
while true | |
Fiber.yield num | |
num += 1 | |
end | |
end | |
all_nums.resume # => 0 | |
all_nums.resume # => 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Object.class_eval do | |
def apply(&block) | |
instance_eval(&block) if block_given? | |
end | |
end | |
arr = [] | |
arr.apply do | |
push [1, 2] | |
p self # => [[1, 2]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ~/.bashrc: executed by bash(1) for non-login shells. | |
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) | |
# for examples | |
shopt -s autocd | |
export ISE_EIFFEL=~/Downloads/Eiffel73 | |
export ISE_PLATFORM=linux-x86 | |
export PATH=$ISE_EIFFEL/studio/spec/$ISE_PLATFORM/bin:~/.bin/elixir-0.10.2/bin/:~/.bin/:$PATH |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ~/.profile: executed by the command interpreter for login shells. | |
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login | |
# exists. | |
# see /usr/share/doc/bash/examples/startup-files for examples. | |
# the files are located in the bash-doc package. | |
# the default umask is set in /etc/profile; for setting the umask | |
# for ssh logins, install and configure the libpam-umask package. | |
#umask 022 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn move-boxes | |
([[box & cboxes] pos] (move-boxes box cboxes pos)) | |
([box cboxes pos] | |
(do some things) | |
(if (> pos 0) | |
(move-boxes box cboxes (dec pos)) | |
(move-boxes cboxes (dec pos))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; 'from' is the current point of search, 'to' is the target, level is the maze/2DMatrix | |
(defn pathar | |
([level from to] (pathar level from to [])) | |
([level from to path] | |
(if (= from to) | |
path | |
(let [nb (valid-neighbours level from)] ;valid neighbours returns the indexes of all valid (in the 2dmatrix) neighbour elements. | |
(pmap #(pathar level % to (cons from path)) nb))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class GroupCalendar < Calendar # Calendar inherits ActiveRecord:Base | |
has_and_belongs_to_many :users | |
has_many :sub_inheritances | |
# has_many :sub_calendars, through: :sub_inheritances, as: :calendarable # <- this line should be as the following: | |
has_many :sub_calendars, through: :sub_inheritances, source: :calendarable, source_type: :Calendar | |
end | |
class SubInheritance < ActiveRecord::Base |
OlderNewer