Skip to content

Instantly share code, notes, and snippets.

@jakebesworth
jakebesworth / godot-clickable-overlap.md
Last active May 4, 2024 22:06
Overlap clickable Area2D's in Godot. Only click the top most node. Also allows clicking outside of clickable nodes (such as to deselect)

Godot Clickable Overlap Objects and Deselect

Summary of Problem

If you want to have objects in your game be clickable, one of the most obvious methods is using a Area2D > Texture + CollisionShape2D. When your mouse interacts with the CollisionShape2D it has mouse motion, mouse exited, and input events.

Note: Control nodes have restrictions, eat up all mouse events, and don't work well with deselecting by clicking outside of any objects

  1. The biggest issue is when you click on overlapping objects it will signal both events asynchronously, so there is not an easy way to differentiate the top object being clicked.
@tangoslee
tangoslee / pica-sample.vue
Created February 12, 2019 08:12
pica - vue.js
<template>
<div class="container">
<div class="col-sm-8">
<h3><button id='upload-btn' class="btn btn-secondary btn-xs" @click="onClick()">Upload</button></h3>
<h3>Preview</h3>
<div class="canvas-containter" id="preview-container">
<!-- <canvas id="preview-pica" class="img-responsive" style="max-width: 300px;"></canvas> -->
<img v-if="previewImage" :src="previewImage" style="max-width: 300px;">
</div>
@slightfoot
slightfoot / download.dart
Created April 13, 2018 22:14
Download file in Dart/Flutter
static var httpClient = new HttpClient();
Future<File> _downloadFile(String url, String filename) async {
var request = await httpClient.getUrl(Uri.parse(url));
var response = await request.close();
var bytes = await consolidateHttpClientResponseBytes(response);
String dir = (await getApplicationDocumentsDirectory()).path;
File file = new File('$dir/$filename');
await file.writeAsBytes(bytes);
return file;
}
import 'package:flutter/material.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
title: 'Flutter Demo',
theme: new ThemeData(
@joshbuchea
joshbuchea / semantic-commit-messages.md
Last active May 18, 2024 23:08
Semantic Commit Messages

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

@zcaceres
zcaceres / Nested-Routers-Express.md
Last active April 4, 2024 09:44
Child Routers in Express

Nested Routers in Express.js

Express makes it easy to nest routes in your routers. But I always had trouble accessing the request object's .params when you had a long URI with multiple parameters and nested routes.

Let's say you're building routes for a website www.music.com. Music is organized into albums with multiple tracks. Users can click to see a track list. Then they can select a single track and see a sub-page about that specific track.

At our application level, we could first have a Router to handle any requests to our albums.

const express = require('express');
@marcoskubis
marcoskubis / table-ellipsis.css
Created February 24, 2017 13:08
Bootstrap table ellipsis
.table.table-ellipsis tbody td {
max-width: 100px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap
}
@dianjuar
dianjuar / Install update WordPress puglins directly.md
Last active April 16, 2024 12:21
Install update WordPress plugins without providing ftp access

Install WordPress plugins directly (without FTP)

Put this on your wp-config.php

/* That's all, stop editing! Happy blogging. */
define('FS_METHOD', 'direct');
@neguse11
neguse11 / node-js-mailgun-via-api.js
Created October 31, 2015 10:48
Call Mailgun API from node.js with Request
// node.js : Mailgun via API
var request = require('request')
var apiBaseUrl = 'https://api.mailgun.net/v3/sandboxXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.mailgun.org';
var apiKey = 'key-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
var from = 'Excited User';
var to = 'example@example.com';
var subject = 'Hello';
var text = 'Testing some Mailgun awesomness!';
@asleepwalker
asleepwalker / remove-polygon-holes.js
Last active December 4, 2021 05:13
Remove holes from multipolygons in geojson file
// DEPS: npm install jsts@0.17.0
// USAGE: node remove_holes.js holey_coverage.geojson solid_coverage.geojson
var fs = require('fs');
var jsts = require("jsts");
var parser = new jsts.io.GeoJSONParser();
var geojson = JSON.parse(fs.readFileSync(process.argv[2], 'utf8'));
var removedHoles = 0;