Skip to content

Instantly share code, notes, and snippets.

View nightire's full-sized avatar
Looking for new opportunities

余凡 nightire

Looking for new opportunities
View GitHub Profile
@rbranson
rbranson / gist:03d88e3733c6ee098a89
Last active July 25, 2017 15:17
My Thoughts on Rust

Rust is the first language that has emerged in the past few years that solves enough of my problems that it would be worth not only learning & teaching an entirely new language, but also sacrificing the maturity of the language ecosystems I’ve become accustomed to.

I highly suggest you read the "Guide" provided by the language developers or this won't make much sense. These are just some of my thoughts and are intended to highlight particular things that stand out to me. I am just a practitioner and not an expert in any of these languages, so I have probably made some incorrect assumptions and out-of-date assertions. Bare with me.

Rust feels like the first time momentum has gained behind a true systems programming language that uses modern PL design techniques to prevent common errors when dealing with memory. It seems like others have previously either been too anemic to be worth adopting or too abstract to provide proper control. The type system and assignment semantics are designed specifically to preven

@ctechols
ctechols / Page.vim
Last active May 15, 2018 10:48
Capture output from a vim command (like :version or :messages) into a split scratch buffer.
"Examples:
":Page version
":Page messages
":Page ls
"It also works with the :!cmd command and Ex special characters like % (cmdline-special)
":Page !wc %
"Capture and return the long output of a verbose command.
function! s:Redir(cmd)
let output = ""
redir =>> output
@lifeart
lifeart / make-tracked.js
Created September 8, 2019 00:06
GlimmerX autotracked objects
function makeTracked(obj) {
function shouldDeepTrack(value) {
return typeof value === 'object' && value !== null;
}
Object.keys(obj).forEach((key)=>{
const value = obj[key];
tracked(obj, key);
if (shouldDeepTrack(value)) {
obj[key] = makeTracked(value);
} else {
@gossi
gossi / idea.md
Last active March 19, 2021 13:33
Ember: Universal a11y helpers

Universal a11y Helpers

Given the WAI ARIA authoring practices tell you quite good how a particular widget shall behave. What - in case you are developing such a widget as a glimmer component - if you want to write tests for them? What if there is an already ready library of tests to use for them? If you as a developer did a good job and have all the markup done properly, the tests can entirely work on the accessibility tree on top of your markup. If not, the tests will fail anyway.

What about having an ember addon, that provides this a11y test library? In case you are developing a new component, you take that library and throw their tests at your code, without ever writing them yourself and be assured your component is a11y compliant. That library would do a service to the whole ember community.

Example

Here is an example, I've just finished writing. It is the first iteration, I found it quite well and useful and lead me to writing this. Basically, I was

@Alonski
Alonski / application.hbs
Created February 19, 2020 20:52
Ember.JS Ember Animated Route Transition Animations
<AnimatedOrphans />{{outlet}}
@lifeart
lifeart / index.html
Last active May 24, 2021 18:56
GlimmerLite web components example
<!doctype html>
<html>
<head>
<title>Glimmer Demo</title>
</head>
<body>
<script src="./app.bundle.js"></script>
<example-app />
</body>
</html>
#!/bin/bash
SOURCE=/tmp/int.erl
COMPILED=/tmp/int.beam
test -e $SOURCE || curl https://raw.githubusercontent.com/josevalim/otp/c7e82c6b406b632a191c791a1bd2162bde08f692/lib/debugger/src/int.erl > $SOURCE
erlc -o ${COMPILED%int.beam} $SOURCE
chmod 444 $COMPILED
chgrp admin $COMPILED
import Controller from '@ember/controller';
import { tracked } from '@glimmer/tracking';
import { cached } from 'tracked-toolbox';
import { scheduleOnce } from '@ember/runloop';
const Observers = [];
class Observer {
tags = [];
cb = null;

Cheat sheet: modules

Named exports, named imports, namespace imports

If we put export in front of a named entity inside a module, it becomes a named export of that module. All other entities are private to the module.

//===== lib1.mjs =====
// Named exports
@lifeart
lifeart / ember-cli-build.js
Last active January 28, 2022 18:57
Minimal Ember 3.28 app with runtime-defined components
'use strict';
const EmberApp = require('ember-cli/lib/broccoli/ember-app');
module.exports = function (defaults) {
let app = new EmberApp(defaults, {});
// we need to add emebr-template-compiler into runtime
app.import('node_modules/ember-source/dist/ember-template-compiler.js');