Skip to content

Instantly share code, notes, and snippets.

View sasknot's full-sized avatar
:octocat:

Rafael Silva sasknot

:octocat:
View GitHub Profile
import { useRoute } from 'vue-router'
const route = useRoute()
export default function useRouteQuery () {
return {
getRouteQuery (key: string) {
const { [key]: value } = route.query
return Array.isArray(value) ? value[0] : value
},
@sasknot
sasknot / _setup.js
Last active April 13, 2023 15:01
JavaScript benchmark example
const arr = ['love', 'lovec', 'wlovec', 'asdlov123', 'abc123']
const word = 'love'
@sasknot
sasknot / navicat_reset_trial.sh
Created December 14, 2022 17:13 — forked from tuxity/navicat_premium_reset_trial.sh
Reset Navicat Premium 15/16 remaining trial days
#!/bin/bash
set -e
file=$(defaults read /Applications/Navicat\ Premium.app/Contents/Info.plist)
regex="CFBundleShortVersionString = \"([^\.]+)"
[[ $file =~ $regex ]]
version=${BASH_REMATCH[1]}
export PATH=~/.npm-global/bin:$PATH
export PATH="/Applications/Sublime Text.app/Contents/SharedSupport/bin:$PATH"
export PATH="/Applications/Visual Studio Code.app/Contents/Resources/app/bin:$PATH"
alias ll='ls -lh'
alias dockerps="docker ps -a --format \"table {{.ID}}\t{{.Image}}\t{{.RunningFor}}\t{{.Status}}\t{{.Ports}}\t{{.Names}}\""
eval "$(/opt/homebrew/bin/brew shellenv)"
@sasknot
sasknot / script.ts
Created November 18, 2021 19:56
Get X.509 Certificate SHA-1 Thumbprint (nodejs)
import crypto from 'crypto'
const x509Certificate = '[insert certificate here]'
const certificateStrings = x509Certificate.match(/-----BEGIN CERTIFICATE-----\s*([\s\S]+?)\s*-----END CERTIFICATE-----/i)
if (certificateStrings && certificateStrings[1]) {
throw new Error('Invalid certificate')
}
const sha1Thumbprint = crypto
# http://editorconfig.org
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
@sasknot
sasknot / script.ts
Last active November 3, 2021 16:09
AWS Lambda Invoking (aws-sdk v2)
import AWSLambda from 'aws-sdk/clients/lambda'
import { mode, modeIsDev } from '@/environment'
import type AWSSES from 'aws-sdk/clients/ses'
const lambda = new AWSLambda({
endpoint: modeIsDev ? 'http://localhost:3002' : undefined
})
const response = await lambda.invoke({
FunctionName: `myApi-${mode}-email`,
@sasknot
sasknot / index.js
Created March 23, 2020 14:55
JS: Remove chars from ending
output.split('').slice(0, -3).join('') + '.000'
Ex:
'1000000'.split('').slice(0, -3).join('') + '.000' // 1000.000
'100000'.split('').slice(0, -3).join('') + '.000' // 100.000
'10000'.split('').slice(0, -3).join('') + '.000' // 10.000
@sasknot
sasknot / prevent-scroll.coffee
Last active February 4, 2016 07:23
Prevent scroll
# Functions to disable/enable scroll
scrollPreventDefault = (e) ->
e = e or window.event
if e.preventDefault
e.preventDefault()
e.returnValue = false
keydown = (e) ->
t = [37,38,39,40]
@sasknot
sasknot / script
Created July 2, 2014 20:00
Commom select2 types
(function($){
'use strict';
$.fn.applySelect2 = function() {
this.filter('.select2-no-search').each(function(){
var options = $(this).data('options') || {};
$.extend( options, { minimumResultsForSearch: -1 } );
$(this).data('options', options);