Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
What Does The Cat Say?

Yanlin Jiang cncolder

:octocat:
What Does The Cat Say?
View GitHub Profile
@cncolder
cncolder / gist:97b0e048ef1b756f25df814faacfd2e7
Last active Apr 16, 2021
VSCode Jest run it extension monorepo bin path
View gist:97b0e048ef1b756f25df814faacfd2e7
// VSCode Settings - Jest run it - Jest Path
node -e '[_,f,...a]=process.argv;d=path.dirname(f).replace(/\\/g,"");j=require.resolve("jest",{paths:[d]});b=path.resolve(j,"../../bin/jest.js");child_process.spawnSync(b,[f,...a],{cwd:d,stdio:"inherit"})'
@cncolder
cncolder / .eslintrc.js
Last active Sep 11, 2020
A way to hack create-react-app for custom config
View .eslintrc.js
// Put me under ./src
module.exports = {
extends: 'react-app',
rules: {
eqeqeq: 'off'
}
}
View lazy factory girl.rb
# spec/factories.rb
class F
class << self
{:a => :attributes_for, :b => :build, :c => :create, :d => :define, :s => :stub, :* => :sequence, :+ => :next}.each do |k,v|
delegate v, :to => Factory
alias_method k, v
end
end
end
View application.js
//BUGFIX: Chromeframe miss some features.
(function($) {
$.oldAjax = $.ajax;
$.ajax = function(o) {
// I can't detect it by navigator.userAgent. So I set it on server side.
if (navigator.chromeframe) {
// Chromeframe can't send DELETE and PUT verb.
if (o.type == "DELETE") {
o.type = "POST";
View application.html.erb
<!-- Hold it in application.html.erb or ur own default layout. for this example put in navigator. -->
<% if @win_ie_with_chromeframe %>
<script>
navigator.chromeframe = true;
</script>
<% end -%>
View rails.js
// Live is new method in jQuery 1.4+.
$('a[data-confirm]').live('click', function () { ... });
// When user click the link. jQuery will handle it and send a ajax request.
$.ajax({
url: "/users/new",
dataType: "script",
...
});
View user.html.erb
<!-- Rails html5 templete -->
<%= link_to "Add user", new_user_path, :remote => true %>
<!-- Will product -->
<a href="/users/new" data-remote="true">Add user</a>
View Concat my name use ruby magic.rb
# Print "colder"
(_=%!%!<<(?#+?@))&&_%(?#+?@)+_%(?/+?@)+_%(?,+?@)+_%(?$+?@)+_%(?%+?@)+_%(?#+?%+?*)
View gist:410523
<html>
<head>
<title>IE PNG Alpha Fix</title>
<style type="text/css">
img { behavior: url("iepngfix.htc") }
</style>
</head>
<body bgcolor="#000000">
<img src="opacity.png"/>
</body>
View Adobe Air2rc1 drag List item to Trash or RecycleBin.mxml
<s:List dragEnabled="true" dragMoveEnabled="true">
<s:dataProvider>
<s:ArrayCollection>
<fx:Object label="Item one"/>
<fx:Object label="Item two"/>
<fx:Object label="Item three"/>
</s:ArrayCollection>
</s:dataProvider>
</s:List>