Skip to content

Instantly share code, notes, and snippets.

View egoist's full-sized avatar
🙏
Please support my open-source projects!

EGOIST egoist

🙏
Please support my open-source projects!
View GitHub Profile
paul = new
@name = 'paul'
@age = 25
# LiveScript has real object comprehensions
flip = (obj) -> new
for own k, v of obj then @[v] = k
foo = 'key'
bar = {(foo): 5, "dyna#foo": 6} #=> {'key': 5, 'dynakey': 6}
# in destructuring
{(+* .>>. 1): middle} = [1 to 7] # middle = 4
{username ? 'root', password || '', secure && 'https'
|| 'http'} = config<[ USERNAME PASSWORD SECURE ]>
class Person
# defaults @name to [], and assigns the first element
set-first-name: (@[]names.0) ->
# defaults @name to [], and adds the element (* being the array's length)
add-name: (@[]names[*]) ->
# defaults @hair to {}, and assigns color
set-hair-color: (@{}hair.color) ->
posts['op' ...'replies'] = thread
# even with objects
extended = {...base, +extended}
# basic backpipe usage
toCase \up <| \hello
# let's say that, if we have no page, we need to create an un element
# with a li element containing 1
pages.appendChild <| do
node 'ul' className: 'ui-pagination'
..appendChild node 'li' innerHTML: '1'
td = node 'td' class: 'informations' innerHTML: do
i18n.get-translation 'informations' .format-for @user
# use do and backcall
promises =
value: do
var App = React.createClass({
getInitialState: function () {
return {
name: 'I\'m Kevin, click me to change my name'
}
},
handleClick: function () {
this.setState({
name: 'Peter is here now!'
})
var App = React.createClass({
getInitialState: function () {
return {
checked: false
}
},
handleCallbackCheck: function (checked) {
this.setState({
checked: checked
})
@egoist
egoist / app.js
Last active November 27, 2015 04:15
import revue from './revue'
Vue.use(revue, {
store: require('./store')
})