Skip to content

Instantly share code, notes, and snippets.

View ppazos's full-sized avatar
🌎
All around

Pablo Pazos Gutiérrez ppazos

🌎
All around
View GitHub Profile
// Originally inspired by David Walsh (https://davidwalsh.name/javascript-debounce-function)
// Returns a function, that, as long as it continues to be invoked, will not
// be triggered. The function will be called after it stops being called for
// `wait` milliseconds.
const debounce = (func, wait) => {
let timeout;
return function executedFunction(...args) {
const later = () => {
@pierrejoubert73
pierrejoubert73 / markdown-details-collapsible.md
Last active May 24, 2024 14:17
How to add a collapsible section in markdown.

How to add a collapsible section in markdown

1. Example

Click me

Heading

  1. Foo
  2. Bar
    • Baz
  • Qux
@jahe
jahe / oauth-cheetsheet.txt
Last active December 8, 2020 18:08
OAuth Cheatsheet
OAuth (Open Authentication)
OAuth Client - e.g. My Server
OAuth Provider - e.g. Facebook Server
1. Register the OAuth Client on the OAuth Provider
2. It gets back an Client ID and a Client Secret
(On FB you do this manually by creating a developer account)
3. We want to authorize a user via the OAuth Provider
We send to "GET: provider.com/oauth/authorize?" with
@trandaison
trandaison / starUML.md
Last active May 23, 2024 18:15
Get full version of StarUML
@nbkhope
nbkhope / grailsFileUpload.groovy
Created January 16, 2017 03:49
Grails 3 File Upload
// In your controller, use the following code
// Single file
def file = request.getFile("identifier_name_in_html_tag_attribute")
// Useful information
file.empty
file.class // => class org.springframework.web.multipart.support.StandardMultipartHttpServletRequest$StandardMultipartFile
file.name // the name attribute value you used above (comes from html input tag)
file.originalFilename
@sujeet100
sujeet100 / MapDiff.groovy
Created January 13, 2017 06:42
Groovy script to find out the difference between two maps. Can be useful to debug failing unit tests when the objects in comparison are big jsons.
def mapDiff(Map m1, Map m2, String path="") { m1.each{k,v->
if(m2[k] != m1[k]) {
if(m1[k] in Map) {
mapDiff(m1[k] as Map, m2[k] as Map, "${path}${k}.")
}
else {
println("${path}${k} ->");
println("\texpected: ${m1[k]}")
println("\tactual: ${m2[k]}")
if (m1[k] in List) {
// Groovy map-reduce example
// declare a closure
def half = { it ->
it / 2
}
// declare another closure
def sum = { result, i ->
result + i
@citrusui
citrusui / dropdown.md
Last active May 15, 2024 01:34
"Dropdowns" in Markdown
How do I dropdown?
This is how you dropdown.

<details>
<summary>How do I dropdown?</summary>
<br>
This is how you dropdown.
@justjanne
justjanne / Price Breakdown.md
Last active April 11, 2024 22:21 — forked from kylemanna/price.txt
Server Price Breakdown: DigitalOcean, Amazon AWS LightSail, Vultr, Linode, OVH, Hetzner, Scaleway/Online.net:

Server Price Breakdown: DigitalOcean, Amazon AWS LightSail, Vultr, Linode, OVH, Hetzner, Scaleway/Online.net:

Permalink: git.io/vps

$5/mo

Provider Type RAM Cores Storage Transfer Network Price
@two7sclash-zz
two7sclash-zz / gist:c3835d83695b46ca2a6a4b6d71272538
Created November 29, 2016 19:39
Groovy Convert To Camel Case or Snake Case
static String toCamelCase( String text, boolean capitalized = false ) {
text = text.replaceAll( "(_)([A-Za-z0-9])", { Object[] it -> it[2].toUpperCase() } )
return capitalized ? capitalize(text) : text
}
static String toSnakeCase( String text ) {
text.replaceAll( /([A-Z])/, /_$1/ ).toLowerCase().replaceAll( /^_/, '' )
}