Skip to content

Instantly share code, notes, and snippets.

@sleungcy
sleungcy / rails_migration_cheatsheet.md
Last active August 29, 2015 14:27 — forked from amejiarosario/rails_migration_cheatsheet.md
Rails Migration - Cheatsheet
@sleungcy
sleungcy / user.rb
Created March 9, 2016 00:51
Rails question
class User < ActiveRecord::Base
def test
puts "#{user_name.blank?}" # outputs false
if false
user_name = "this_should_never_run"
end
puts "#{user_name.blank?}" # outputs true
end
end
{
"modules": {
"/mnt/myapp/app/assets/javascripts/app/_stream_0.js": {
"source": "\"use strict\";\n\nvar a = require(\"./a.json\");\nvar b = require(\"./b.json\");\n//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIl9zdHJlYW1fMC5qcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLElBQUksSUFBRSxRQUFRLFVBQVIsQ0FBRjtBQUNKLElBQUksSUFBRSxRQUFRLFVBQVIsQ0FBRiIsImZpbGUiOiJfc3RyZWFtXzAuanMiLCJzb3VyY2VzQ29udGVudCI6WyJ2YXIgYT1yZXF1aXJlKFwiLi9hLmpzb25cIilcbnZhciBiPXJlcXVpcmUoXCIuL2IuanNvblwiKVxuIl19",
"entry": true,
"file": "/mnt/myapp/app/assets/javascripts/app/_stream_0.js",
"id": "/mnt/myapp/app/assets/javascripts/app/_stream_0.js",
"order": 0,
"deps": {
"./a.json": "/mnt/myapp/app/assets/javascripts/app/a.json",
@sleungcy
sleungcy / weird_output_from_browserify.js
Created March 11, 2016 23:51
multiple module.exports chained together?
....
};
exports.shr64_lo = shr64_lo;
},{"inherits":"/mnt/talemetry_apply/node_modules/browserify/node_modules/inherits/inherits_browser.js"}],"/mnt/talemetry_apply/node_modules/browserify/node_modules/crypto-browserify/node_modules/browserify-sign/node_modules/elliptic/package.json":[function(require,module,exports){
module.exports=module.exports=module.exports={
"name": "elliptic",
"version": "6.2.3",
"description": "EC cryptography",
"main": "lib/elliptic.js",
16:51 sleungcy: I needed to include the polyfill in the end to get function name to work on ie10
16:51 sleungcy: but shouldn't the transformer have dealt with that already? I don't understand why I would stlil need the polyfill
16:53 loganfsmyth: sleungcy: are you saying it works other browsers but not IE10?
16:53 sleungcy: yes (function x(){}).name isn't supported by IE10
16:54 sleungcy: but i thought the transformer-es2015-function-name is for that purpose?
16:54 ljharb: Torkable: vim can read from ./node_modules/.bin/eslint tho
16:54 sleungcy: or is it for something completely different, I wasn't sure if I am thinking right
16:54 ljharb: sleungcy: loganfsmyth: there's always https://www.npmjs.com/package/function.prototype.name :-D
16:55 ljharb: that shims it in IE 9 - 11
16:55 loganfsmyth: sleungcy: no, `function-name` converts `var foo = function(){}` into `var foo = function foo(){}` so that the function has a name
@sleungcy
sleungcy / colorInConsole.groovy
Created February 16, 2019 01:47 — forked from crevier/colorInConsole.groovy
How to print color in console in groovy
def fg = 30
def bg = 46
def style = "${(char)27}[$fg;$bg"+"m"
println(style+"HELLO")
/*
+~~~~~~+~~~~~~+~~~~~~~~~~~+
| fg | bg | color |
+~~~~~~+~~~~~~+~~~~~~~~~~~+
| 30 | 40 | black |
| 31 | 41 | red |
{
"name": "SuperPool",
"description": "The pool that tests all the pools",
"ticker": "Spool",
"homepage": "https://PooPooPool.com"
}
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIF4yuwNgZ6+J0wUeOD4IONZqLMz3ta+ZidC0TTjHF8cd your_email@example.com