Skip to content

Instantly share code, notes, and snippets.

@shanecelis
shanecelis / DragManipulator.cs
Last active March 31, 2024 15:58
This manipulator makes a visual element draggable at runtime in Unity's UIToolkit.
/* Original code[1] Copyright (c) 2022 Shane Celis[2]
Licensed under the MIT License[3]
[1]: https://gist.github.com/shanecelis/b6fb3fe8ed5356be1a3aeeb9e7d2c145
[2]: https://twitter.com/shanecelis
[3]: https://opensource.org/licenses/MIT
*/
using UnityEngine;
using UnityEngine.UIElements;
@RISCfuture
RISCfuture / typescript-vue.md
Last active June 3, 2023 05:48
Adding TypeScript to a Rails + Webpacker + Vue project

Adding TypeScript to a Rails + Webpacker + Vue project

These instructions assume you already have a Rails 5.2 project using Webpacker 4 with Vue 2 and Vuex 3. I'll show you how to add TypeScript to the project, and type-safe your Vue components, including single-file components (SFCs). This document will not teach you TypeScript syntax or type theory. It also assumes your code already works without TypeScript. You shouldn't use this article to, for example, get started with Vuex, because I'm leaving out lots of necessary boilerplate code and focusing just on TypeScript changes.

If you want to see a commit on a project accomplishing this migration, visit https://github.com/RISCfuture/AvFacts/commit/666a02e58b4626a074a03812ccdd193a3891a954.

Setup

  1. Run rails webpacker:install:typescript. This should modify config/webpacker.yml and config/webpack/environment.js (leave those changes), add tsconfig.json and config/webpack/loaders/typescript.js (leave those files), and add some other files in `a
@chantastic
chantastic / on-jsx.markdown
Last active March 20, 2024 01:03
JSX, a year in

Hi Nicholas,

I saw you tweet about JSX yesterday. It seemed like the discussion devolved pretty quickly but I wanted to share our experience over the last year. I understand your concerns. I've made similar remarks about JSX. When we started using it Planning Center, I led the charge to write React without it. I don't imagine I'd have much to say that you haven't considered but, if it's helpful, here's a pattern that changed my opinion:

The idea that "React is the V in MVC" is disingenuous. It's a good pitch but, for many of us, it feels like in invitation to repeat our history of coupled views. In practice, React is the V and the C. Dan Abramov describes the division as Smart and Dumb Components. At our office, we call them stateless and container components (view-controllers if we're Flux). The idea is pretty simple: components can't

@demirhanaydin
demirhanaydin / tire-parent-child-example.rb
Last active December 22, 2015 23:48
Elasticsearch parent/child example with tire
require 'rubygems'
require 'tire'
Tire.configure { logger 'elasticsearch.log', :level => 'debug' }
class Document
attr_accessor :title, :content
include Tire::Model::Persistence
include Tire::Model::Search
include Tire::Model::Callbacks
@niuage
niuage / Quest mode in Google Maps
Created June 14, 2012 15:03
How to add the Quest mode in Google Maps from April Fools Day 2012
// Set map options
var mapOptions = {
center: new google.maps.LatLng(41.917142, -87.673837), // Or whatever
zoom: 15,
mapTypeId: "quest",
mapTypeControlOptions: {
mapTypeIds: [google.maps.MapTypeId.ROADMAP, google.maps.MapTypeId.SATELLITE, "quest"]
},
scrollwheel: false
}
@postmodern
postmodern / c_parser.rb
Created January 16, 2011 04:24
An ANSI C Parser using the Ruby Parslet library.
#
# A C Parser using the Parslet library.
#
# ANSI C Grammar:
#
# * http://www.lysator.liu.se/c/ANSI-C-grammar-l.html
# * http://www.lysator.liu.se/c/ANSI-C-grammar-y.html
#
require 'parslet'