Skip to content

Instantly share code, notes, and snippets.

View pavloo's full-sized avatar
🎯
Focusing

Pavlo Osadchyi pavloo

🎯
Focusing
View GitHub Profile
(defun find-idx-of-max (list)
(let ((max_i 0) (val) (max))
(dotimes (i (length list) max_i)
(setq val (nth i list))
(setq max (nth max_i list))
(when (> val max) (setq max_i i))
)
)
)
(defun read-words-from-file (file-path)
(with-temp-buffer
(insert-file-contents file-path)
(mapcar 'string-to-number (split-string (buffer-string) "\n" t))
)
)
(read-words-from-file "./input.txt")
(defun escape-maze (list)
(defun read-words-from-file (file-path)
(with-temp-buffer
(insert-file-contents file-path)
(mapcar 'split-string (split-string (buffer-string) "\n" t))
)
)
(defun is-all-unique (list predicate)
(let ((n (1- (length list))) (has-similar))
(loop
(defun size-of-square (N)
(let ((d 1))
(loop
(when (>= (* d d) N) (return d))
(setq d (+ d 2))
)
)
)
(defun generate-empty-square (size)
(defun read-numbers-from-file (file-path)
(with-temp-buffer
(insert-file-contents file-path)
(mapcar
(lambda (arg) (mapcar 'string-to-number(split-string arg)))
(split-string (string-trim (buffer-string)) "\n" t)
)
)
)
;; Part 1
(defun sum (list)
"Solution for Part #1 http://adventofcode.com/2017/day/1"
(let ((s 0) next-i next val (n (length list)))
(dotimes (i n)
(progn
(setq val (nth i list))
(setq next-i (+ i 1))
(when (= next-i n) (setq next-i 0))
(setq next (nth next-i list))
import Ember from 'ember';
export default Ember.Component.extend({
tagName: 'span',
actions: {
highlight(part, event) {
this.get('message').forEach((part) => {
part.set('isHighlighted', false);
});
@pavloo
pavloo / application.controller.js
Last active March 16, 2016 23:21
registerWaiter illustartion
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
actions: {
insert(){
// set timeout is used intentionally
// (instead of Ember.run.later)
setTimeout(()=>{
@pavloo
pavloo / application.controller.js
Created February 9, 2016 20:42
Nested Routes Hooks
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle'
});
@pavloo
pavloo / gist:cfc4ff41741d43fdb04b
Created July 22, 2014 15:52
Metaprog in Ember
Ember.Application.initializer({
name: 'authenticated-routes',
after: 'simple-auth',
initialize: function(container, application) {
var routeNames = Object.keys(Teachertrainingv2.Router.router.recognizer.names),
routeObj = null;
var systemRoutes = ['loading', 'error', 'application'];
var routesWithoutAuth = systemRoutes.concat(Teachertrainingv2.ROUTES_NOT_REQUIRE_AUTHENTICATION);