Skip to content

Instantly share code, notes, and snippets.

@airyboy
airyboy / keybindings.json
Created November 8, 2018 06:50
entries to use alt+j, alt+k for intellisense in VSCode
{
"key": "alt+k",
"command": "selectNextSuggestion",
"when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus"
},
{
"key": "alt+j",
"command": "selectPrevSuggestion",
"when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus"
}
@airyboy
airyboy / camelCase.cs
Created September 6, 2017 12:16
Newtonsoft.Json, transform names to camelCase through Contract Resolver option
JsonConvert.SerializeObject(
<YOUR OBJECT>,
new JsonSerializerSettings
{
ContractResolver = new CamelCasePropertyNamesContractResolver()
});
var myFun = debounce(() => console.log('call'), 1000);
myFun();
myFun();
myFun(); //only this call will be called
function debounce(fn, delay) {
let isActivated = false;
return function() {
@airyboy
airyboy / console.log.js
Last active September 6, 2017 12:18
Redirecting console.log output to a webpage
<pre id="log"></pre>
(function(){
var oldLog = console.log;
console.log = function (message) {
const logger = document.getElementById('log');
logger.innerHTML += `> ${message}\n`;
oldLog.apply(console, arguments);
};
@airyboy
airyboy / currency.js
Created November 16, 2016 13:28
Currency formatting
let sum = 123456.78;
sum.toLocaleString('ru-RU', {style: 'currency', currency: 'RUR'});
//"123 456,78 RUR"
@airyboy
airyboy / gist:08ae28635e0a6d5df54f2bf04235751e
Last active September 25, 2016 07:37
Center div in another div horizontally
#container {
width: 640px; /*can be in percentage also.*/
margin: 0 auto;
}
@airyboy
airyboy / one_liners.rb
Last active September 24, 2015 20:50
Ruby one-liners
#Sum a list of numbers:
(1..1000).inject { |sum, n| sum + n }
#Sum a list of numbers:
(1..1000).inject(&:+)
#Sum a list of numbers:
(1..1000).inject(:+)
#Filter a list of numbers:
[49, 58, 76, 82, 88, 90].partition { |n| n > 60 }