Skip to content

Instantly share code, notes, and snippets.

@masahirompp
masahirompp / controller.js
Created February 21, 2015 12:09
javascript mvc (no framework) http://jsfiddle.net/54sjqL6z/
(function(todo) {
'use strict';
// viewの追加イベントを監視。TodoListに新規Todoを追加する。
todo.View.on('add', function(description) {
todo.TodoList.add(new todo.Todo(todo.TodoList.length, description));
todo.View.clearInput();
});
// viewの変更イベントを監視。モデルの状態を更新を命令。
@hashrock
hashrock / vuejs.md
Last active October 5, 2023 23:42
Vue.js資料まとめ(古いので注意)

#まず見るべき

以下のURLは、常に更新されているコンテンツです。

@varlen
varlen / scriptingBridge.py
Created June 3, 2016 01:01
Apple Scripting Bridge example
from Foundation import *
from ScriptingBridge import *
# Returns the methods of the object
def __methods( theObject ):
return [method for method in dir(theObject) if callable(getattr(theObject, method))]
# Elements present in one list but not in the other
def __diffList( A, B):
return list( set( A ) - set( B ) )
@developit
developit / example.js
Last active May 6, 2024 05:10
Preact + Web Components = <333 Demo: http://www.webpackbin.com/VJyU9wK5W
import { h, Component } from 'preact';
import Markup from 'preact-markup';
import register from './preact-custom-element';
// just a proxy component: WC -> Preact -> WC
const A = () => <x-b foo="initial foo from <x-a>" />;
// stateful component that can re-render
class B extends Component {
render(props, state) {
##Some points to mention...
##
##The model knows nothing about the view or the controller.
##The view knows nothing about the controller or the model.
##The controller understands both the model and the view.
##
##The model uses observables, essentially when important data is changed,
##any interested listener gets notified through a callback mechanism.
##
##The following opens up two windows, one that reports how much money you
@jnewc
jnewc / NotesApp.swift
Last active January 21, 2024 17:40
A notes app written in >100 lines of swift using SwiftUI
import SwiftUI
let dateFormatter = DateFormatter()
struct NoteItem: Codable, Hashable, Identifiable {
let id: Int
let text: String
var date = Date()
var dateText: String {
dateFormatter.dateFormat = "MMM d yyyy, h:mm a"
// Created by gil_birman on 11/22/19.
import Combine
import FirebaseFirestore
import FirebaseStorage
import Foundation
enum FirebaseCombineError: Error {
case encodeImageFailed
case nilResultError