Skip to content

Instantly share code, notes, and snippets.

View malina's full-sized avatar
🌴

Alexandr Shumov malina

🌴
View GitHub Profile
@malina
malina / moon.rb
Created October 7, 2024 08:07 — forked from nofxx/moon.rb
#
# Lunar/Moon phases ruby class
#
# Code is based upon Bradley E. Schaefer''s moon phase algorithm.
# Ruby version based on JavaScript Phase Calculator by Stephen R. Schmitt
class Moon
attr_reader :epoch, :phase, :days, :icon, :dist, :ll
# Return the current (or input a date) moon.
# Moon.new
@malina
malina / clear-sidekiq-jobs.sh
Last active January 10, 2025 13:12 — forked from wbotelhos/clear-sidekiq-jobs.sh
Clear Sidekiq Jobs
require 'sidekiq/api'
# 1. Clear retry set
Sidekiq::RetrySet.new.clear
# 2. Clear scheduled jobs
Sidekiq::ScheduledSet.new.clear
@malina
malina / sidekiq_transfer.rake
Created March 24, 2020 04:14 — forked from jagthedrummer/sidekiq_transfer.rake
Rake task to transfer Sidekiq jobs from one redis instance to another
# This task should be run inside an environment that is already configured to connect to the redis
# instance that we're transfering AWAY FROM.
#
# The task should be handed the URL of the redis instance that we're MOVING TO.
#
# To run it and pass in the destination Redis you'd do something like this:
# rake sidekiq:transfer[redis://...]
#
# As jobs are added to the destination Redis, they're deleted from the source Redis. This
# allows the task to be restarted cleanly if it fails in the middle due to a network error
@malina
malina / AnimatedGate.jsx
Created December 12, 2019 06:01 — forked from wachunei/AnimatedGate.jsx
Replicating Twitter iOS splash screen animation on React Native during redux rehydration
import React, { Component } from 'react';
import { Animated, Easing, StatusBar, MaskedViewIOS, View } from 'react-native';
class AnimatedGate extends Component {
constructor(props) {
super(props);
this.beginAnimation = this.beginAnimation.bind(this);
this.state = {
animation: new Animated.Value(0),
};
@malina
malina / sidekiq_delete_jobs.md
Created March 29, 2019 08:41 — forked from eparreno/sidekiq_delete_jobs.md
How to delete Sidekiq jobs in a Rails app using ActiveJobs

How to delete Sidekiq jobs in a Rails app using ActiveJobs

Sidekiq jobs can be enqueued or scheduled. Enqueued means that they are gonna be picked up as soon as possible, scheduled jobs will be enqueued at some specific time.

job_id and jid

When using ActiveJobs, Rails will return a job_id after sending the job to ActiveJobs

job = UserMailer.send_invite(params).deliver_later
@malina
malina / Dokku v0.5.6 Rails App.md
Created March 27, 2019 03:28 — forked from Epigene/Dokku v0.5.6 Rails App.md
Knowledge-Base for getting a Rails5 app with Cable running on dokku v0.5.6

Dokku v0.5.6 Rails workflow

Straight to Maintenance

0. Set up Droplet

Initialize the droplet with dokku app pre-setup
@malina
malina / Component.js
Created November 26, 2018 15:14 — forked from smontlouis/Component.js
React Native - Fixed header/footer disappearing on scroll
import React, { PropTypes, Component } from 'react'
import {
Animated,
ScrollView,
Text,
View,
} from 'react-native'
import EStyleSheet from 'react-native-extended-stylesheet'
const styles = EStyleSheet.create({
import React, {Component} from "react";
import {Animated, Dimensions, Platform, Text, View} from 'react-native';
import {Body, Header, List, ListItem as Item, ScrollableTab, Tab, Tabs, Title} from "native-base";
const NAVBAR_HEIGHT = 56;
const {width: SCREEN_WIDTH} = Dimensions.get("window");
const COLOR = "rgb(45,181,102)";
const TAB_PROPS = {
tabStyle: {width: SCREEN_WIDTH / 2, backgroundColor: COLOR},
activeTabStyle: {width: SCREEN_WIDTH / 2, backgroundColor: COLOR},
@malina
malina / automigrate.js
Created November 6, 2018 15:55
[LB4] Loopback 4 Automigrate Example (example/todo-list)
// Place in app root, build project (e.g: 'npm start'), execute (e.g. 'node automigrate.js')
const {DbDataSource} = require('./dist/src/datasources/db.datasource.js');
const {TodoRepository} = require('./dist/src/repositories/todo.repository.js');
const {TodoListRepository} = require('./dist/src/repositories/todo-list.repository.js');
const db = new DbDataSource();
const repoTodo = new TodoRepository(db);
const repoTodoList = new TodoListRepository(db);
@malina
malina / Guardian JWT.md
Created September 14, 2018 15:52 — forked from nikneroz/Guardian JWT.md
Elixir + Phoenix Framework + Guardian + JWT. This is tutorial and step by step installation guide.

Elixir + Phoenix Framework + Guardian + JWT + Comeonin

Preparing environment

We need to generate secret key for development environment.

mix phoenix.gen.secret
# ednkXywWll1d2svDEpbA39R5kfkc9l96j0+u7A8MgKM+pbwbeDsuYB8MP2WUW1hf

Let's generate User model and controller.