timestamp with time zone
does not actually save the time zone information
int[][] arr;
Arrays.sort(arr, Comparator.comparingInt(o -> o[1]));
// Decending
Arrays.sort(arr, Comparator.comparingInt(o -> -o[1]));
// Alternatively
Arrays.sort(arr, ((o1, o2) -> o1[1] - o2[1]));
// Alternatively
Arrays.sort(arr, ((o1, o2) -> Integer.compare(o1[1], o2[1])));
prebuild
custom platform hook
# .platform/hooks/prebuild/01_add_swap_memory.sh
#!/bin/bash
set -o xtrace
set -e
if grep -E 'SwapTotal:\s+0+\s+kB' /proc/meminfo; then
echo "no swap space identified, creating some."
dd if=/dev/zero of=/var/swapfile bs=1M count=512
/sbin/mkswap /var/swapfile
chmod 000 /var/swapfile
/sbin/swapon /var/swapfile
else
echo "doing nothing."
fi
$ jshell
jshell> System.out.println("Welcome to JShell")
Welcome to JShell
jshell> /exit
| Goodbye
leader_only
:
if [[ "$EB_IS_COMMAND_LEADER" == "true" ]]; then
//script
fi
$ ./bin/rails g migration PkDefaultUUID
class PkDefaultUUID < ActiveRecord::Migration[6.1]
def change
enable_extension 'pgcrypto'
end
end
run the migration: $ ./bin/rails db:migrate
class CreateWorld < ActiveRecord::Migration
def change
create_table :worlds, id: :uuid do |t|
t.string :population
end
end
end
IntStream.range(0, n).forEach(i -> {
System.out.println(i);
});
// If order matters
IntStream.range(0, n).forEachOrdered(i -> {
System.out.println(i);
});
NoSuchElementException
, Java stream returns an OptionaInt
int[] arr;
int max = Arrays.stream(arr).max().getAsInt();
// Arrays.stream(arr).max() returns an OptionalInt hence the use of getAsInt()
// check for charater in a string
1. str.indexOf(ch);
2. str.contains(String.valueOf(ch));
3. str.contains("" + ch);
1. peer-to-peer WebRTC is more suited to limited number of participants
2. heavy computing required to decode and re-encode streams
3. lack of support for certain features on safari and edge
sample_object = 1
sample_array = [1, 2, 3]
[*sample_object].each { |element| p element }
[*sample_array].each { |element| p element }
# ruby
Array.new(10) { rand 50 } # ruby
# python
from random import randint
[randint(0, 50) for p in range(0, 10)]
// Java
Random random = new Random();
random.ints(10,0,50).toArray()
.ebextensions
folder need to be migrated to .platform/hooks
class ExampleClass {
// Instance Initialization Block
{
System.out.println("I perform additional operations while assigning value");
}
}
create_or_find_by
as an improvement over find_or_create_by
to avoid stale reads between SELECT and INSERT