This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'eventmachine' | |
class Server | |
attr_accessor :connections | |
def initialize | |
@connections = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# WARN: this relies on the single threaded nature of our apps! | |
class ApplicationModel < ActiveRecord::Base | |
before_save do | |
if ChangeTracking.currently_change_tracking? | |
changeset << [:update, self, changes] | |
end | |
end | |
before_create do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
########################################################################### | |
# | |
# Created by | |
# Bohdan Kossak, CryptoLions.io | |
# | |
# Auto Installer for Jungle Network Generated by Monitor | |
########################################################################### |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# from https://forum.micropython.org/viewtopic.php?p=19988&sid=7aaeff853648d6cd65371661708c1fba#p19988 | |
import network | |
import time | |
import uos | |
from machine import Pin | |
led = Pin(2, Pin.OUT) | |
led.off() # actually turns it on | |
sta_if = network.WLAN(network.STA_IF) | |
sta_if.active(True) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# encoding: utf-8 | |
Encoding.default_external = "UTF-8" | |
Encoding.default_internal = "UTF-8" | |
require "open-uri" | |
require "json" | |
require "net/https" | |
require "uri" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# see: https://github.com/rails/rails/issues/32467 | |
# written with help from: https://github.com/noise-machines | |
# sponsored by: https://www.hiresuccess.com/ | |
require "active_support/concern" | |
module ReplaceNilsWithColumnDefaults | |
extend ActiveSupport::Concern | |
included do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module SoftDeletable | |
extend ActiveSupport::Concern | |
included do | |
default_scope { where(deleted_at: nil) } | |
scope :deleted, -> { unscope(where: :deleted_at).where.not(deleted_at: nil) } | |
end | |
def delete | |
self.touch(:deleted_at) if has_attribute? :deleted_at |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
// This file was originally written by @drudru (https://github.com/drudru/ansi_up), MIT, 2011 | |
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | |
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | |
var ANSI_COLORS = [[{ color: "0, 0, 0", "class": "ansi-black" }, { color: "187, 0, 0", "class": "ansi-red" }, { color: "0, 187, 0", "class": "ansi-green" }, { color: "187, 187, 0", "class": "an |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# spec/support/requests/auth_helpers.rb | |
module Requests | |
module AuthHelpers | |
module Extensions | |
def sign_in(user) | |
let(:auth_helpers_auth_token) { | |
self.public_send(user).create_new_auth_token | |
} | |
end |