Skip to content

Instantly share code, notes, and snippets.

View Sija's full-sized avatar

Sijawusz Pur Rahnama Sija

View GitHub Profile
@Sija
Sija / ameba-updater.cr
Created October 12, 2023 23:58
Poor man's @dependabot-style updater for ameba
require "colorize"
require "log"
require "yaml"
# ---
target_version = "~> 1.5.0"
root_dir = "~/Code"
paths = %w[
@Sija
Sija / presence.ex
Created May 24, 2023 16:38
Presence protocol for Elixir
defprotocol Presence do
@doc "Determines whether the value is present and truthy"
def present?(data)
end
defimpl Presence, for: Atom do
def present?(false), do: false
def present?(nil), do: false
def present?(_), do: true
end
@Sija
Sija / EventServiceProvider.php
Created December 8, 2021 00:53
Identify users in Laravel 8.x for Sentry
<?php
class EventServiceProvider extends ServiceProvider
{
/**
* The subscriber classes to register.
*
* @var array
*/
protected $subscribe = [
macro string_enum(name, &block)
enum {{name}}
{% for exp in block.body.expressions %}
{% if exp.is_a?(Assign) %}
{{exp.target}}
{% else %}
{{exp}}
{% end %}
{% end %}
struct Synchronized(T)
protected getter __wrapped__ : T
def initialize(wrapped : T = T.new, protection : Mutex::Protection = :reentrant) forall T
@__wrapped__ = wrapped
@__lock__ = Mutex.new(protection)
end
macro method_missing(call)
@__lock__.synchronize do
@Sija
Sija / run-with-retry-on-pattern.yaml
Created April 11, 2020 01:29
CircleCI Orb allowing to retry jobs failing with certain pattern
# This code is licensed from CircleCI to the user under the MIT license. See
# https://circleci.com/orbs/registry/licensing for details.
version: 2.1
description: Run commands with retry
commands:
run-with-retry:
description: Run command with retry
parameters:
@Sija
Sija / angular-typeform.coffee
Last active October 8, 2018 23:34
Typeform embed module for AngularJS 1.x
'use strict'
###*
# @ngdoc overview
# @name angularTypeform
# @description
# This module contains a directive that allows you easily embed a typeform
# in your angular 1.x app taking care about state changes
###
angular.module 'angularTypeform', []
startup_message off
#defbce on
#deflog on
ignorecase on
vbell on
autodetach on
altscreen on # fix for residual editor text
defutf8 on
hardcopy_append on
compacthist on
@Sija
Sija / build_nginx.sh
Last active March 30, 2017 00:20 — forked from MatthewVance/build_nginx.sh
Fetch, build, and install the latest nginx with the latest OpenSSL for RaspberryPi
#!/usr/bin/env bash
# make script exit if a simple command fails and
# make script print commands being executed
set -e -x
# names of latest versions of each package
export VERSION_PCRE=pcre-8.39
export VERSION_OPENSSL=openssl-1.0.2f
export VERSION_NGINX=nginx-1.9.11
module MacroMagic
def initialize(**attributes)
{% for var in @type.instance_vars %}
if arg = attributes[:{{var.name.id}}]?
@{{var.name.id}} = arg
end
{% end %}
end
private def instance_var_get(name)