Skip to content

Instantly share code, notes, and snippets.

View arslan-gg's full-sized avatar
:electron:

Arslan R. arslan-gg

:electron:
View GitHub Profile
@arslan-gg
arslan-gg / trim.java
Created September 2, 2021 10:15
Trim string value in Java
public String trim(String value, int maxLength) {
return value.substring(0, Math.min(value.length(), maxLength));
}
@arslan-gg
arslan-gg / one_of.java
Created September 2, 2021 10:13
Get random value from provided list.
@SafeVarargs
public final <T> T oneOf(T... values) {
return values[faker.number().numberBetween(0, new Random().nextInt(values.length))];
}
@arslan-gg
arslan-gg / app_name.service
Last active September 2, 2021 10:17
systemd service script
# service configuration example
[Unit]
Description=AppName
Requires=network.target
[Service]
Type=simple
User=your_user_name
Group=your_user_group
@arslan-gg
arslan-gg / migration_name_201709030744.rb
Created September 3, 2017 04:46
How to store coordinates in Ruby on Rails
class CreatePlaces < ActiveRecord::Migration[5.1]
def change
create_table :places do |t|
t.decimal "lat", precision: 10, scale: 6
t.decimal "lng", precision: 10, scale: 6
end
end
end