Skip to content

Instantly share code, notes, and snippets.

View ollietreend's full-sized avatar

Ollie Treend ollietreend

View GitHub Profile
@peteryates
peteryates / 0_wtf.md
Last active June 4, 2024 13:45
Calling Nunjucks from Ruby

Ever wanted to render nunjucks macros from Ruby? Neither have I, until half an hour ago.

Here's a quick approach using the excellent Schmooze from Shopify.

Screenshot from 2020-08-01 16-28-12

Try it yourself

Save nunjucks.rb in a new directory then:

@guycalledseven
guycalledseven / manual-uninstall-parallels.sh
Last active May 15, 2024 01:09
Manually remove Parallels Desktop v15 leftovers MacOS
# used different forum posts/guides to figure this out like:
# The uninstall script is located at /Library/Parallels/Parallels Service.app/Contents/Resources
# https://github.com/danijeljw/remparallels/blob/master/remprls.sh
# https://kb.parallels.com/122461
# sudo find / -iname "*parallels*"
# sudo find / -iname "*prl*"
#before uninstalling deactivate your licencse - this won't be possible after uninstall
prlsrvctl deactivate-license
@castwide
castwide / rails.rb
Last active April 27, 2024 08:54
Enhance Rails Intellisense in Solargraph
# The following comments fill some of the gaps in Solargraph's understanding of
# Rails apps. Since they're all in YARD, they get mapped in Solargraph but
# ignored at runtime.
#
# You can put this file anywhere in the project, as long as it gets included in
# the workspace maps. It's recommended that you keep it in a standalone file
# instead of pasting it into an existing one.
#
# @!parse
# class ActionController::Base
require 'cgi'
require 'active_support'
def verify_and_decrypt_session_cookie(cookie, secret_key_base = Rails.application.secret_key_base)
config = Rails.application.config
cookie = CGI::unescape(cookie)
salt = config.action_dispatch.authenticated_encrypted_cookie_salt
encrypted_cookie_cipher = config.action_dispatch.encrypted_cookie_cipher || 'aes-256-gcm'
# serializer = ActiveSupport::MessageEncryptor::NullSerializer # use this line if you don't know your serializer
serializer = ActionDispatch::Cookies::JsonSerializer
@dam1
dam1 / resumableUpload.js
Created January 8, 2018 13:44
Resumable Upload Google Drive Api - Node Js
var fs = require('fs');
var request = require('request');
var EventEmitter = require('events').EventEmitter;
var mime = require('mime');
var util = require('util');
function resumableUpload() {
this.byteCount = 0; //init variables
this.tokens = {};
this.filepath = '';
@wbotelhos
wbotelhos / clear-sidekiq-jobs.sh
Last active June 13, 2024 22:47
Clear Sidekiq Jobs
require 'sidekiq/api'
# 1. Clear retry set
Sidekiq::RetrySet.new.clear
# 2. Clear scheduled jobs
Sidekiq::ScheduledSet.new.clear
@lkraider
lkraider / gs-resample.sh
Created March 7, 2017 20:06
Ghostscript PDF quality downsample
#!/bin/sh
# It seems it's very hard to set resample output quality with Ghostscript.
# So instead rely on `prepress` preset parameter to select a good /QFactor
# and override the options we don't want from there.
gs \
-o resampled.pdf \
-sDEVICE=pdfwrite \
-dPDFSETTINGS=/prepress \
@bpevs
bpevs / FreshInstall.md
Last active November 15, 2021 06:41
A list of stuff I use on a fresh reinstall
<?php
// put array in here
$array = array (
'key' => 'group_54624ad06f391',
'title' => 'Company List',
'fields' => array (
array (
'key' => 'field_54624aff43237',
'label' => 'Companies',
@pschultz
pschultz / ForceCharsetPlugin.php
Last active December 9, 2021 16:26
Guzzle plugin to force the response charset. Useful ~if~ when webservers lie to you again.
<?php
use Guzzle\Common\Event;
use Guzzle\Http\Message\Header;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class ForceCharsetPlugin implements EventSubscriberInterface
{
private $forcedCharset = 'utf8';