Skip to content

Instantly share code, notes, and snippets.

View lukaswilkeer's full-sized avatar

Lukas Wilkeer lukaswilkeer

View GitHub Profile
@takanuva
takanuva / agt.h
Last active July 25, 2022 19:57
Simple generic print() and scan() macros
/*******************************************************************************
* Copyright 2022 Paulo Torrens *
* *
* 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: *
* *
@tsrivishnu
tsrivishnu / docker-increase-inotify-max-user-watches.md
Last active April 8, 2024 12:15
Increase inotify watchers in Docker images during build

Increasing fs.inotify.max_user_watches for Docker images

TL;DR You can't set those for an image during build time becasue Docker takes the sysctl configuration from the Host. So, set the config on your host machine.

As in this link, to increase the maximum watchers, we need set fs.inotify.max_user_watches to a higher number in /etc/sysctl.conf.

@busypeoples
busypeoples / FlowTutorial.js
Last active July 17, 2023 10:12
Flow Fundamentals For JavaScript Developers
//
// MIT License
//
// Copyright (c) 2018 Ali Sharif
//
// 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
@Madh93
Madh93 / Ruby_Proxy_Pattern_And_Metaprogramming.md
Last active December 11, 2020 01:03
Ruby, Proxy Pattern and Metaprogramming

Ruby, Proxy Pattern and Metaprogramming

You have this class:

class BankAccount
  attr_reader :balance

  def initialize(starting_balance = 0)
 @balance = starting_balance
@lukaswilkeer
lukaswilkeer / rules.js
Last active September 8, 2019 11:39
tiny-validator
const rules = {
'env': {
rule: (value) => rules.env.property.includes(value)
, property: ['production', 'sandbox']
, default: 'sandbox'
, errorMsg: 'Env must be production or sandbox'
},
'email': {
rule: (value) => value ? true : false
'use strict'
/**/
function moda (arr) {
return ((arr.sort((a, b) =>
(arr.filter(v => v === a).length) - (arr.filter(v => v === b).length))
).pop())
}
module.exports = moda
console.log(moda([1,2,3,4,5])) //amodal nao tem moda(nao deveria aparecer nada)

Contributing

When contributing to this repository, please first discuss the change you wish to make via issue, email, or any other method with the owners of this repository before making a change.

Please note we have a code of conduct, please follow it in all your interactions with the project.

Pull Request Process

  1. Ensure any install or build dependencies are removed before the end of the layer when doing a
@joyrexus
joyrexus / README.md
Last active June 8, 2023 07:45
form-data vs -urlencoded

Nice answer on stackoverflow to the question of when to use one or the other content-types for POSTing data, viz. application/x-www-form-urlencoded and multipart/form-data.

“The moral of the story is, if you have binary (non-alphanumeric) data (or a significantly sized payload) to transmit, use multipart/form-data. Otherwise, use application/x-www-form-urlencoded.”


Matt Bridges' answer in full:

The MIME types you mention are the two Content-Type headers for HTTP POST requests that user-agents (browsers) must support. The purpose of both of those types of requests is to send a list of name/value pairs to the server. Depending on the type and amount of data being transmitted, one of the methods will be more efficient than the other. To understand why, you have to look at what each is doing

@staltz
staltz / introrx.md
Last active November 20, 2024 07:53
The introduction to Reactive Programming you've been missing
@dfkaye
dfkaye / mocking-private-functions.md
Last active March 13, 2019 15:40
mocking - not testing - private functions in JavaScript, using new Function() - followup to https://gist.github.com/dfkaye/5971486

Mocking - not testing - private functions in JavaScript

Instead of trying to extract a private function, we can rely on mocking/spying. This gist shows how to use the "new Function()" constructor to replace an internal call so that we can mock, spy or stub.

Another response to @philwalton - 
http://philipwalton.com/articles/how-to-unit-test-private-functions-in-javascript/

This is a followup to https://gist.github.com/dfkaye/5971486 - a suggestion for 
*annotating* functions to be extracted and tested separately (publicly).