Skip to content

Instantly share code, notes, and snippets.

🎯
Busy
Focusing

Quentin Rousseau kwent

View GitHub Profile
@kwent
kwent / cancelable.rb
Created Dec 30, 2018
Cancelable Rails concern
View cancelable.rb
module Cancelable
extend ActiveSupport::Concern
included do
scope :with_cancelled, -> { where.not(cancelled_at: nil) }
scope :not_cancelled, -> { where(cancelled_at: nil) }
def cancel
# Use update_attributes and not touch to trigger after_save
View activestorage.rb
# config/initializers/activestorage.rb
Rails.application.config.to_prepare do
# Provides the class-level DSL for declaring that an Active Record model has attached blobs.
ActiveStorage::Attached::Macros.module_eval do
def has_one_attached(name, dependent: :purge_later, acl: :private)
class_eval <<-CODE, __FILE__, __LINE__ + 1
def #{name}
@active_storage_attached_#{name} ||= ActiveStorage::Attached::One.new("#{name}", self, dependent: #{dependent == :purge_later ? ":purge_later" : "false"}, acl: "#{acl}")
end
@kwent
kwent / kubernetes_deis_local.md
Last active Mar 15, 2017 — forked from kerin/kubernetes_deis_local.md
Local Kubernetes/Deis environment
View kubernetes_deis_local.md
@kwent
kwent / exit_code.bash
Created Mar 9, 2016
Echo command exit code
View exit_code.bash
#!/bin/bash
set -o errexit # Always use `errexit`
run_the_cmd && code=$? || code=$?
echo "The exit code was: $code" >&2
@kwent
kwent / sftp.rb
Last active Feb 27, 2018
Create a ruby pseudo terminal (PTY) and invoke an interactive command (SFTP)
View sftp.rb
require 'pty'
require 'expect'
PTY.spawn('sftp username@sftp.domain.com:/uploads') do |input, output|
# Say yes to SSH fingerprint
input.expect(/fingerprint/, 2) do |r|
output.puts "yes" if !r.nil?
View IonIcons+Additions+.h
//
// IonIcons+Additions+.h
// Created by Quentin Rousseau on 24/10/14.
// http://quent.in
//
#import <Foundation/Foundation.h>
#import "IonIcons.h"
@interface IonIcons (Additions)
View STDataStoreController.h
//
// STDataStoreController.h
//
// Created by Buzz Andersen on 3/24/11.
// Copyright 2011 System of Touch. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
@kwent
kwent / iron_requeuing_jobs.rb
Last active Aug 29, 2015
IronWorker Requeuing Jobs | Ruby script.
View iron_requeuing_jobs.rb
#=============================================================================
#title :iron_requeuing_jobs.rb
#description :This script is requeing jobs by job status to Iron Worker
#author :Quentin Rousseau <contact@quent.in>
#date :2014-07-23
#version :1.0
#usage :ruby iron_requeuing_jobs.rb
#dependencies :gem install iron_worker_ng
#==============================================================================
@kwent
kwent / mixpanel_people_export.rb
Last active Sep 16, 2015
Export all MixPanel People to a JSON file
View mixpanel_people_export.rb
#==========================================================================================
#title :mixpanel_people_export.rb
#description :This ruby script is exporting mixpanel people json data to a file
#author :Quentin Rousseau <contact@quent.in>
#date :2014-07-15
#version :1.0
#usage :ruby mixpanel_people_export.rb
#dependencies :gem install 'mixpanel_client'
#moreinfo :https://mixpanel.com/docs/api-documentation/data-export-api#engage-default
#===========================================================================================
@kwent
kwent / backup_neo4j_to_s3.sh
Last active May 21, 2018
NEO4J Backup to AWS S3 Shell Script
View backup_neo4j_to_s3.sh
#!/bin/sh -
#title :backup_neo4j_to_s3.sh
#description :This script is creating a NEO4J Backup through neo4j-backup tool,
# compress the backup folder via LZMA2 algorithm compression, and upload it to AWS S3.
#author :Quentin Rousseau <contact@quent.in>
#date :2014-07-28
#version :1.1
#usage :sh backup_neo4j_to_s3.sh ip port destination | eg. sh backup_neo4j_to_s3.sh 127.0.0.1 6362 /mnt/datadisk/backup
#dependencies :apt-get update && apt-get install p7zip-full && apt-get install awscli.
#==============================================================================
You can’t perform that action at this time.