Skip to content

Instantly share code, notes, and snippets.

View piclez's full-sized avatar

Peter WD piclez

View GitHub Profile
@sajadtorkamani
sajadtorkamani / five-digit.js
Created February 6, 2020 16:19
Insert 5 digit to obtain maximum value
const solution = num => {
const isNegativeNum = num < 0;
const numStr = Math.abs(num).toString();
const permutations = [];
for (let i = 0; i <= numStr.length; i++) {
const permutation = Number(numStr.substr(0, i) + '5' + numStr.substr(i));
permutations.push(permutation);
}
@Merott
Merott / tailwind-colors-as-css-variables.md
Last active July 7, 2025 22:40
Expose Tailwind colors as CSS custom properties (variables)

This is a simple Tailwind plugin to expose all of Tailwind's colors, including any custom ones, as custom css properties on the :root element.

There are a couple of main reasons this is helpful:

  • You can reference all of Tailwind's colors—including any custom ones you define—from handwritten CSS code.
  • You can define all of your colors within the Tailwind configuration, and access the final values programmatically, which isn't possible if you did it the other way around: referencing custom CSS variables (defined in CSS code) from your Tailwind config.

See the Tailwind Plugins for more info on plugins.

@fyr91
fyr91 / face_detection.py
Created October 30, 2019 03:26
real time face detection with an ultra_light_model
# -*- coding: utf-8 -*-
# @Author: fyr91
# @Date: 2019-10-22 15:05:15
# @Last Modified by: fyr91
# @Last Modified time: 2019-10-30 11:25:26
import cv2
import numpy as np
import onnx
import onnxruntime as ort
from onnx_tf.backend import prepare
@henrypoydar
henrypoydar / Environment variables in Heroku
Last active March 19, 2023 18:13
Rails + Sidekiq + Puma + Heroku
WEB_PROCESSES=2
WEB_THREADS=5
WORKER_THREADS=15
@ZakharDay
ZakharDay / set_locale.rb
Created April 26, 2019 10:05
How to set locale on Rails with cookies
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
before_action :set_locale
private
# Before every request, we set the locale, from the specified or detected settings, or from the cookie
def set_locale
if language_change_necessary?
I18n.locale = the_new_locale
set_locale_cookie(I18n.locale)
@jtubert
jtubert / shortcut_upload_s3.js
Created January 27, 2019 03:22
Upload photo to S3 from ios shortcut
const util = require('util');
const AWS = require('aws-sdk');
module.exports = function (context, cb) {
if(context.body && context.body.base64Image){
uploadFromShortcut(context, cb);
return;
}
};
# Copyright 2018 Stanko K.R. <[email protected]>
#
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
# documentation files (the "Software"), to deal in the
# Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute,
# sublicense, and/or sell copies of the Software, and to permit
# persons to whom the Software is furnished to do so, subject
# to the following conditions:
@JuanVqz
JuanVqz / simple_form_bulma.rb
Last active September 12, 2024 19:31
Support for simple form with bulma css, copy and paste on config/initializers/simple_form_bulma.rb
# frozen_string_literal: true
# Use this setup block to configure all options available in SimpleForm.
SimpleForm.setup do |config|
# Default class for buttons
config.button_class = "button"
# Define the default class of the input wrapper of the boolean input.
config.boolean_label_class = "checkbox"
@amiralles
amiralles / btree.rb
Last active November 5, 2024 10:54
General purpose binary tree implemented in Ruby.
class BTree
attr_accessor :root, :size
class Node
attr_accessor :parent, :data, :left, :right
def initialize parent, data
self.parent = parent
self.data = data
end
@thefonso
thefonso / findNumber.js
Created October 22, 2018 02:52 — forked from dre4success/cloudSettings
Given an unsorted array of n elements, find if the element k is present in the given array or not. return 'YES' or 'NO'
function findNumber(arr, k) {
let result = 'NO';
arr.forEach(item => {
if(k === item) {
return result = 'YES';
}
})
return result;
}