Skip to content

Instantly share code, notes, and snippets.

View xcambar's full-sized avatar

Xavier Cambar xcambar

View GitHub Profile
@xcambar
xcambar / app_components_throw-test.js
Created January 29, 2020 11:55
Testing component initialisation and required arguments in Ember 3.15 (Octane)
import Component from '@glimmer/component';
export default class ThrowTestComponent extends Component {
constructor() {
super(...arguments)
if (!this.args.test) {
throw new Error('hello')
}
}
}
@xcambar
xcambar / controllers.application.js
Last active December 6, 2018 13:36
textarea demo
import Ember from 'ember';
export default Ember.Controller.extend({
testString: 'Ember Twiddle'
});
import Component from '@ember/component'
export default Component.extend({
tagName: '',
aIsChecked: false,
bIsChecked: false,
someOtherMethod() {
console.log('someOtherMethod() this = ', this)
},
someMethod() {
@xcambar
xcambar / strip_tags.js
Last active September 3, 2018 09:42
Efficiently and securely remove <script> tags from source HTML
// This code would normally inject global variables and run an alert
// if injected in your document naively
const source = '<p>bla <script>window.SHIT=true</script></p><script>alert("SHIT")</script>'
// Crete a DocumentFragment from the source HTML
const frag = document.createRange().createContextualFragment(source)
// Remove all the <script> nodes
[...frag.querySelectorAll('script')].forEach((e)=> {
e.parentNode.removeChild(e)
@xcambar
xcambar / controllers.application.js
Created April 20, 2018 18:29
ember-modal-dialog: double onClose call
import Ember from 'ember';
export default Ember.Controller.extend({
countClose: 0,
incCloseCount() {
this.incrementProperty('countClose');
}
});
@xcambar
xcambar / vagrant.sh
Last active February 2, 2017 10:53
Show vagrant status
[ -e .vagrant ] && (VBoxManage showvminfo $(cat .vagrant/machines/default/virtualbox/id) --machinereadable | grep 'VMState=' | sed 's/.*"\(.*\)"[^"]*$/\1/)
@xcambar
xcambar / controllers.application.js
Created January 18, 2017 18:06
ember-one-way-controls radio bug
import Ember from 'ember';
export default Ember.Controller.extend({
myValue: '?',
actions: {
setToSomethingElse() {
this.set('myValue', 'something else');
}
}
});

Keybase proof

I hereby claim:

  • I am xcambar on github.
  • I am xcambar (https://keybase.io/xcambar) on keybase.
  • I have a public key ASBzE-UDKYiIs5y1i-k-VVup6VcmZ-S_OqHnKS-q2RjeAQo

To claim this, I am signing this object:

Starting BrowserStack Local { key: 'XXX...', force: true }
BrowserStack Local started
Started child process for: chrome 52 environment
Started child process for: chrome 51 environment
Started child process for: ie 11 environment
Started child process for: ie 10 environment
Started child process for: ie 9 environment
Started child process for: safari 9.1 environment
Started child process for: safari 8 environment
Started child process for: safari 7.1 environment
@xcambar
xcambar / docker_machine_indicator.sh
Created February 23, 2016 13:48
Indicates the currently active docker machine, if any.
function docker_indicator() {
if [[ -n "$DOCKER_MACHINE_NAME" ]]; then
echo "%F{blue}(🐳 $DOCKER_MACHINE_NAME)%f"
fi
}