Skip to content

Instantly share code, notes, and snippets.

View ricardovelero's full-sized avatar

Ricardo Rodriguez ricardovelero

View GitHub Profile
@ricardovelero
ricardovelero / gist:2ddab433f3ab5227970107b0745beb65
Created November 4, 2023 16:40
Simple React select search example
'use client';
import React, { useState } from 'react';
import { Input } from '@/components/ui/input';
import { cn } from '@/lib/utils';
import { fetchFilteredPlaces } from '@/lib/data';
export default function SearchDemo() {
const [query, setQuery] = useState('');
const [departure, setDeparture] = useState('');
@ricardovelero
ricardovelero / add_unaccent_to_postgres
Created December 28, 2022 11:24 — forked from AlexVKO/add_unaccent_to_postgres
Adding extensions to Postgresql database with Rails
The default Postgresql installation on Mac OS X using homebrew includes a single extension - plpgsql (PL/pgSQL procedural language) but there are a number of them available in the lib directory (/usr/local/Cellar/postgresql/9.2.1/lib on my machine)
To install an extension into the database, the easiest way I found was to open a database console using the 'rails db' command and then create it directly. I have seen mention of doing this in a Rails migration but this did not work for me.
Note that an extension is installed in a specific database, rather than being added to all databases.
The command to list the installed extensions is '\dx'
$ rails db
psql (9.2.1)
@ricardovelero
ricardovelero / ethminer_ubuntu_nvidia.md
Created December 19, 2018 20:28 — forked from johnstcn/ethminer_ubuntu_nvidia.md
NVIDIA/CUDA ethminer setup under Ubuntu Server 16.04

Headless Ethminer (nVidia) Setup Guide

Cian Johnston, July 2017

A couple of weeks ago, I decided I should put my gaming rig to work crypto mining. I did not expect to make any significant profit on this, it was more of a fun project to set up. However, there were a large number of tutorials and guides already out there, and many were more than a year out of date.

This guide assumes the reader already has a crypto wallet set up, is comfortable with Linux and the command line, and knows how to use Google if they run into problems.

The end result is an Ubuntu 16.04 LTS headless server running CUDA ethminer via systemd.

Hardware

@ricardovelero
ricardovelero / gist:d88da5df610fb333c2a1
Created February 5, 2016 12:14
Filter WooCommerce shipping methods depending of state in address
/* WooCommerce check for states Florida, Alabama, Georgia, Tennessee, South Carolina, North Carolina,
* Kentucky, Washington D.C., Virginia, and remove UPS 2nd Day Shipping rate if they are present in cart.
* Remove UPS 1-2 Day Ground for the rest of Continental U.S. Works for both WooThemes UPS Shipping and
* Syn Media UPS Shipping.
*/
add_filter( 'woocommerce_package_rates', 'unset_ups_shipping_rates_for_specific_states' , 10, 2 );
function unset_ups_shipping_rates_for_specific_states( $rates, $package ) {
// Setup an array of states that do not allow UPS Shipping 2nd Day Air. As of 10/18/2015 we added 3 days ground too.
$excluded_states = array( 'FL','AL','KY','LA','MS','TN','GA','SC','NC','KY','DC','VA','AR','CT','DE','IL','IN','KS','MA','ME','MD','MN','MI','MO','NH','NJ','NY','OH','OK','PA','RI','TX','VT','WV','WI' );

Add Sublime Text to OS X Context Menu

  • Open Automator
  • Create a new Service
  • Add a Run Shell Script action
  • Set input to Service receives selected files or folders in any application
  • Set the script action to /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl -n $@
  • Set Pass input to as arguments
  • Save as Open in Sublime Text
@ricardovelero
ricardovelero / normalize.css
Created November 5, 2015 13:15
CSS: normalize.css v3.0.3
/*! normalize.css v3.0.3 | MIT License | github.com/necolas/normalize.css */
/**
* 1. Set default font family to sans-serif.
* 2. Prevent iOS and IE text size adjust after device orientation change,
* without disabling user zoom.
*/
html {
font-family: sans-serif; /* 1 */