Skip to content

Instantly share code, notes, and snippets.

View WillDent's full-sized avatar
🏠
Working from home

Will Dent WillDent

🏠
Working from home
View GitHub Profile
@WillDent
WillDent / DestructiveActionGuard.tsx
Created April 15, 2024 02:41 — forked from MarceloPrado/DestructiveActionGuard.tsx
An easy way of seeking user confirmation before proceeding with a destructive action. Demo: https://twitter.com/marceloterreiro/status/1779657639745798411
import type { ReactElement } from "react";
import { cloneElement, memo, useCallback } from "react";
import { AlertV2 } from "@/components/AlertV2/alertV2Helpers";
export interface DestructiveActionGuardProps {
children: ReactElement<{ onPress: () => void }>;
confirmationTitle?: string;
confirmationDescription?: string;
}
@MarceloPrado
MarceloPrado / DestructiveActionGuard.tsx
Last active April 22, 2024 17:35
An easy way of seeking user confirmation before proceeding with a destructive action. Demo: https://twitter.com/marceloterreiro/status/1779657639745798411
import type { ReactElement } from "react";
import { cloneElement, memo, useCallback } from "react";
import { AlertV2 } from "@/components/AlertV2/alertV2Helpers";
export interface DestructiveActionGuardProps {
children: ReactElement<{ onPress: () => void }>;
confirmationTitle?: string;
confirmationDescription?: string;
}
@falkolab
falkolab / SVGProduct.js
Created October 30, 2015 11:47
How to use SVG as autogenerated raster image
// app/lib/SVGProduct.js
function getImageFileFromSVG(svgOpts, name) {
var file = Ti.Filesystem.getFile(Ti.Filesystem.applicationCacheDirectory,
Ti.Utils.md5HexDigest(JSON.stringify(svgOpts)));
if (!file.exists()) {
var SVG = require('com.geraudbourdin.svgview');
if (!file.write(SVG.createView(svgOpts).toImage())) {
Ti.API.error("Can't save to file. Product:", name);
return null;
@grantges
grantges / charts.js
Last active November 13, 2017 18:17
Hyperloop Donut Example using Alloy Custom Tags (charts.js should be put in the app/lib folder of your app)
var Hyperloop = require('hyperloop');
var UIView = require('UIView');
var CGRect = require('CGRect');
var CGPoint = require('CGPoint');
var UIColor = require('UIColor');
var UIBezierPath = require('UIBezierPath');
function DEGREES_TO_RADIANS(angle) { return (Number(angle) / 180.0 * Math.PI) };
@pec1985
pec1985 / uploadImage.js
Created April 27, 2011 02:56
Upload Image
Titanium.Media.openPhotoGallery({
success:function(event){
var myImage = event.media;
var xhr = Titanium.Network.createHTTPClient();
xhr.open('POST','http:// ------ /uploads.php');
xhr.onerror = function(e){alert(e.error);};
xhr.setTimeout(200000);