Skip to content

Instantly share code, notes, and snippets.

View creaturenex's full-sized avatar
🏠
Working from home

Oscar Romero creaturenex

🏠
Working from home
View GitHub Profile
@creaturenex
creaturenex / space_invader.rb
Created February 18, 2021 01:14
space_invader
class Invader
def initialize
self.animate
end
def down
puts " ▒▒ ▒▒"
puts " ▒▒ ▒▒"
puts " ▒▒▒▒▒▒▒▒▒▒▒▒▒▒"
puts " ▒▒▒▒ ▒▒▒▒▒▒ ▒▒▒▒"
You have an application that uses a #fetch method to retrieve a collection of data from some external source and a #save method that saves any modified data when you finish. To make updates easier, you have several methods that update the data based on different search criteria. So far, you have something like this:
Copy Code
def update_data(select_string, block)
data = fetch(select_string)
data.each # you can update or replace this line
save(data)
end
def update_by_type(type) # you can update this method
@creaturenex
creaturenex / ExportKindle.js
Created May 9, 2022 15:46 — forked from jkubecki/ExportKindle.js
Amazon Kindle Export
// The following data should be run in the console while viewing the page https://read.amazon.com/
// It will export a CSV file called "download" which can (and should) be renamed with a .csv extension
var db = openDatabase('K4W', '3', 'thedatabase', 1024 * 1024);
getAmazonCsv = function() {
// Set header for CSV export line - change this if you change the fields used
var csvData = "ASIN,Title,Authors,PurchaseDate\n";
db.transaction(function(tx) {
@creaturenex
creaturenex / gist:b8fbe5783e838a4e4260278ce3f9ae46
Last active December 1, 2022 19:25
shopify coding challenge
def solution(number)
case
when number % 5 == 0 && number % 3 == 0 then "FizzBuzz"
when number % 5 == 0 then "Buzz"
when number % 3 == 0 then "Fizz"
else
number
end
end
@creaturenex
creaturenex / image_processing-on-heroku.md
Created December 2, 2022 00:21 — forked from bigtiger/image_processing-on-heroku.md
How We Deployed Image Processing to Heroku in Support of a Rails 6 Application

How We Deployed Image Processing to Heroku in Support of a Rails 6 Application

Our app was already deployed and working on Heroku with MiniMagick. There were a few features of Image Processing that were appealing, performance and autorotation, and it appeared to be a straightforward swap.

Locally, we had run brew install vips on our MacBooks to get it running. That was early in the process and a detail long forgotten. When I deployed to Heroku @juliancheal pointed out that the staging environment was failing with an ActiveSupport::MessageVerifier::InvalidSignature error.

We were able to quickly identify the missing libvips dependency.

Figuring out how to install libvips to support rubyvips to support Image Processing was not trivial and therefore this guidepost exists.

// Example 1
// Write a function that returns the factorial of a number.
// EXAMPLE4! = 4 * 3 * 2 * 1 = 24, so calling factorial(4) should return 24.
// Initial example as I did not expect the function to use an argument as storage
// function factorial(num) {
// if (num == 1) return num;
// return num * factorial(num - 1);
// };
@creaturenex
creaturenex / gist:314005c5781817ba377689260b7d5c9f
Created December 22, 2022 04:25
Chrome - Stylus plugin - Dark Docs for Google
/* ==UserStyle==
@name Dark Docs
@version 2022.12.17
@namespace userstyles.world/user/winghongchan
@description A dark theme for Google Docs web, based on the colors used in its mobile app.
@author winghongchan
@license No License
@preprocessor less
@var select document-filter "Document filter" {"none:None": "none", "dim:Dim": "contrast(80%) brightness(90%)", "invert:Invert*": "var(--darkfilter)"}
@var number document-contrast "Document contrast while inverted" [80, 40, 100, 1, "%"]
@creaturenex
creaturenex / gist-flat-dark.less
Created December 26, 2022 19:14 — forked from haydenbleasel/gist-flat-dark.less
A collection of GitHub Gist styles and themes.
.gist {
.gist-file {
border: none !important;
margin-bottom: 0 !important;
.gist-data {
border-bottom: 2px solid #7f8c8d !important;
.line-numbers {
border-right: 2px solid #7f8c8d !important;
padding: 1em !important;
}
@creaturenex
creaturenex / csbin - async
Created December 26, 2022 19:15
async problems from csbin
/* CHALLENGE 1 */
function sayHowdy() {
console.log('Howdy');
}
function testMe() {
setTimeout(sayHowdy, 0);
console.log('Partnah');
}
--color-scale-white: #ffffff;
--color-scale-gray-0: #f6f8fa;
--color-scale-gray-1: #eaeef2;
--color-scale-gray-2: #d0d7de;
--color-scale-gray-3: #afb8c1;
--color-scale-gray-4: #8c959f;
--color-scale-gray-5: #6e7781;
--color-scale-gray-6: #57606a;
--color-scale-gray-7: #424a53;
--color-scale-gray-8: #32383f;