Skip to content

Instantly share code, notes, and snippets.

View velrest's full-sized avatar
:shipit:
.

Jonas Cosandey velrest

:shipit:
.
View GitHub Profile
@velrest
velrest / pi.exs
Created June 4, 2021 11:45
Elixir calculate Pi from random points
defmodule Experiment do
def pi( data \\ %{total: 0, circle: 0}, num_points) do
%{total: total, circle: circle} = data
case num_points do
num_points when num_points == 0 ->
4 * circle/total
num_points ->
:math.pow(:rand.uniform, 2) + :math.pow(:rand.uniform, 2)
|> case do
x when x <= 1 ->
import Controller from '@ember/controller';
import Changeset from "ember-changeset";
import {tracked} from "@glimmer/tracking";
import {action, get, computed, defineProperty} from "@ember/object";
export default class ApplicationController extends Controller {
appName = 'Ember Twiddle';
get __val(){
return get(this.model, "greeting.de")
@velrest
velrest / components.my-component\.js
Last active August 5, 2020 09:23
Cycles in tag reprod
import Component from '@glimmer/component';
export default class extends Component {
}
import Ember from 'ember';
export default Ember.Component.extend({
test: "no",
init(){
this._super(...arguments)
this.set("test2", "hi2")
},
didReceiveAttrs(){
console.log(this.test)
@velrest
velrest / adapters.api.js
Last active May 3, 2019 17:36
New Twiddle
import JSONAPIAdapter from "ember-data/adapters/json-api";
import { assert } from '@ember/debug';
export default JSONAPIAdapter.extend({
query(store, modelClass, query, _, options = {}) {
assert("No options supplied", Object.keys(options).length)
// If you now remove this: "._super" from this comment, the options will be passed.
return {data:[]}
}
import JSONAPIAdapter from "ember-data/adapters/json-api";
import { assert } from '@ember/debug';
export default JSONAPIAdapter.extend({
host: "https://baconipsum.com",
query(store, modelClass, query, _, options = {}) {
assert(options.adapterOptions, "Options are not passed")
const res = this._super(...arguments)
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
@velrest
velrest / adapters.application.js
Last active April 15, 2019 14:25
New Twiddle
import JSONAPIAdapter from "ember-data/adapters/json-api";
import { get, computed } from "@ember/object";
import { inject as service } from "@ember/service";
const captureQuery = () => {
return function(store, type, query, options) {
console.error({ options }, {query});
return this._super(...arguments);
};
};
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
import Ember from 'ember';
import EmberObject from '@ember/object';
import Changeset from 'ember-changeset';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
init(){
this._super(...arguments)
let tom = this.store.createRecord('test')