Skip to content

Instantly share code, notes, and snippets.

View Definence's full-sized avatar
🎯
Focusing

Bogdan Yarosh Definence

🎯
Focusing
View GitHub Profile
@TheNaoX
TheNaoX / resque.rake
Created October 22, 2012 22:10 — forked from bkutil/deploy.rb
Start and Stop tasks for resque workers and resque scheduler with capistrano deploy hook (without God)
# Start a worker with proper env vars and output redirection
def run_worker(queue, count = 1)
puts "Starting #{count} worker(s) with QUEUE: #{queue}"
ops = {:pgroup => true, :err => [(Rails.root + "log/workers_error.log").to_s, "a"],
:out => [(Rails.root + "log/workers.log").to_s, "a"]}
env_vars = {"QUEUE" => queue.to_s}
count.times {
## Using Kernel.spawn and Process.detach because regular system() call would
## cause the processes to quit when capistrano finishes
pid = spawn(env_vars, "rake resque:work", ops)
@huacnlee
huacnlee / config.yml
Created December 6, 2018 06:07
CircleCI with Ruby 2.5, Rails 5.2, Yarn, Webpacker, Sass, PostgreSQL, Redis, ElasticSearch full example.
version: 2
jobs:
build:
docker:
- image: circleci/ruby:2.5.3-node-browsers
environment:
RAILS_ENV: test
DATABASE_URL: postgres://postgres@127.0.0.1:5432/rails-test
- image: circleci/postgres:9.6
environment:
@robertsosinski
robertsosinski / application.js
Created April 6, 2009 02:50
Handle cookies betwen JavaScript and Rails with JSON/Hash objects
window.cookies = {
set: function(name, value, days) {
if (name) {
if (days) {
var date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
var expires = "; expires=" + date.toGMTString();
}
else {
var expires = "";
@ezidio
ezidio / jest.config.js
Created March 2, 2018 12:01
Jest transformer to work with webpack's require.context
module.exports = {
verbose: true,
moduleDirectories: ['node_modules'],
transform: {
'\\.js$': '<rootDir>/../build/utils/webpack_polyfill'
}
}
require 'apple_id'
# NOTE: in debugging mode, you can see all HTTPS request & response in the log.
# AppleID.debug!
pem = <<-PEM
-----BEGIN PRIVATE KEY-----
:
:
-----END PRIVATE KEY-----
@searls
searls / whereable.rb
Created September 4, 2021 16:06
The initial implementation of a Whereable query filter for KameSame.
class Whereable
def initialize(where:, model: Item, ranking_conditions: [], valid: true, data_source: nil)
@model = model
@where = where
@data_source = data_source
@ranking_conditions = ranking_conditions
@valid = valid
end
def valid?
@mat
mat / Readme.markdown
Last active February 19, 2024 07:46
apple-app-site-association —with examples

“apple-app-site-association” file

One file for each domain, both www.example.com and example.com need separate files:

{
    "applinks": {
        "apps": [],
        "details": {
 "9JA89QQLNQ.com.apple.wwdc": {
@Therises
Therises / fix_mic_lenovo320.md
Last active February 27, 2024 15:46
Fix microphone on Lenovo IdeaPad 320 on Ubuntu 18.04

In /usr/share/pulseaudio/alsa-mixer/paths/analog-input-internal-mic.conf and /usr/share/pulseaudio/alsa-mixer/paths/analog-input-mic.conf:

  • Under [Element Internal Mic Boost] set volume to zero.
  • Under [Element Int Mic Boost] set volume to zero.
  • Under [Element Mic Boost] set volume to zero

Find your source name from the following command; mine is alsa_input.pci-0000_00_1f.3.analog-stereo

  $ pacmd list-sources | grep 'name:.*input'

Edit /etc/pulse/default.pa and add the following lines, where INPUT_NAME is name of the input source from above step:

@Diasporism
Diasporism / redis_and_resque.mkd
Last active March 13, 2024 08:37
How to configure Redis and Resque for your Rails app.

Redis and Resque

What this guide will cover: the code you will need in order to include Redis and Resque in your Rails app, and the process of creating a background job with Resque.

What this guide will not cover: installing Ruby, Rails, or Redis.

Note: As of this writing I am still using Ruby 1.9.3p374, Rails 3.2.13, Redis 2.6.11, and Resque 1.24.1. I use SQLite in development and Postgres in production.

Background jobs are frustrating if you've never dealt with them before. Over the past few weeks I've had to incorporate Redis and Resque into my projects in various ways and every bit of progress I made was very painful. There are many 'gotchas' when it comes to background workers, and documentation tends to be outdated or scattered at best.

// Файл "tsconfig.json":
// - устанавливает корневой каталог проекта TypeScript;
// - выполняет настройку параметров компиляции;
// - устанавливает файлы проекта.
// Присутствие файла "tsconfig.json" в папке указывает TypeScript, что это корневая папка проекта.
// Внутри "tsconfig.json" указываются настройки компилятора TypeScript и корневые файлы проекта.
// Программа компилятора "tsc" ищет файл "tsconfig.json" сначала в папке, где она расположена, затем поднимается выше и ищет в родительских папках согласно их вложенности друг в друга.
// Команда "tsc --project C:\path\to\my\project\folder" берет файл "tsconfig.json" из папки, расположенной по данному пути.
// Файл "tsconfig.json" может быть полностью пустым, тогда компилятор скомпилирует все файлы с настройками заданными по умолчанию.
// Опции компилятора, перечисленные в командной строке перезаписывают собой опции, заданные в файле "tsconfig.json".