Skip to content

Instantly share code, notes, and snippets.

View nirinchev's full-sized avatar

Nikola Irinchev nirinchev

  • Realm
  • Copenhagen
View GitHub Profile
class Person : RealmObject
{
public string Name { get; set; }
public Person(string name)
{
ValidateName(name);
Name = name;
}
@nirinchev
nirinchev / program.cs
Created February 2, 2022 15:27
Recursive attribute declaration
var recursiveAtt = typeof(MyClass).GetCustomAttributes(inherit: true).Single() as RecursiveAttribute;
Console.WriteLine($"MyClass attribute value: {recursiveAtt.SomeValue}");
var recursiveAttConstructorAtt = recursiveAtt.GetType().GetConstructor(new Type[0]).GetCustomAttributes(inherit: true).Single() as RecursiveAttribute;
Console.WriteLine($"MyClass attribute's ctor's attribute value: {recursiveAttConstructorAtt.SomeValue}");
// Prints:
// MyClass attribute value: cde
using System;
using System.Collections.Generic;
using System.Diagnostics;
namespace ListVSHashSet
{
class Program
{
static void Main(string[] args)
{
using System;
using System.Text;
class Solution
{
static void ReduceString(StringBuilder sb)
{
if (sb.Length > 1)
{
@nirinchev
nirinchev / translate.js
Last active June 20, 2017 14:49
A simple example showcasing calling google translate API from a realm function
// Make sure to npm install node-google-translate-skidz
// More info: https://realm.io/docs/realm-object-server/#calling-node-modules-from-realm-functions
let translate = require('node-google-translate-skidz');
module.exports = function(changeEvent) {
let realm = changeEvent.realm;
for (let className in changeEvent.changes) {
if (className !== 'TranslateRequest') {
return;
sudo crontab -e
# choose your favourite editor and paste this at the bottom of the file
0 4 * * * certbot renew --renew-hook /etc/realm/keys/post-renew.sh --quiet
sudo certbot renew --renew-hook /etc/realm/keys/post-renew.sh --force-renewal
#!/bin/sh
set -e
for domain in $RENEWED_DOMAINS; do
case $domain in
ros.myserver.com) # <- Update this with your own server
realm_cert_root=/etc/realm/keys
# Make sure the certificate and private key files are
sudo mkdir /etc/realm/keys
sudo chown realm:realm /etc/realm/keys
sudo chmod 500 /etc/realm/keys
# install certbot
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:certbot/certbot
sudo apt-get update
sudo apt-get install certbot
# fire it up in certonly mode
sudo certbot certonly