Skip to content

Instantly share code, notes, and snippets.

View xdumaine's full-sized avatar
🦄

Xander Dumaine xdumaine

🦄
View GitHub Profile
@xdumaine
xdumaine / svgexport-rn.js
Created November 19, 2019 16:47
svg export for various react-native icon sizes
const svgExport = require("svgexport");
const output = process.argv[2];
const input = process.argv[3];
const images = [
[".android.png", "36:"],
["@1.5x.android.png", "54:"],
["@2x.android.png", "72:"],
["@2x.ios.png", "72:"],
["@3x.android.png", "108:"],
["@3x.ios.png", "108:"],
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@xdumaine
xdumaine / lazyload.js
Last active November 12, 2018 17:33
Lazy
/* lazyload.js (c) Xander Dumaine
* MIT License (http://www.opensource.org/licenses/mit-license.html)
*
* Adapted from https://css-tricks.com/snippets/javascript/lazy-loading-images/
*
* expects a bunch of
* `<img src="blank.gif" data-src="my_image.png">`
*/
!function (window) {
@xdumaine
xdumaine / webrtc.svg
Last active July 3, 2017 08:59
An svg of the webrtc logo, suitable for use as icon. Created "by eye" by Xander Dumaine
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
for(i=1;i<101;i++){r=i%3?'':'fizz';r+=i%5?'':'buzz';!r||console.log(r)}
var baseAddress = new Uri(API_URL_BASE);
var cookieContainer = new CookieContainer();
using (var handler = new HttpClientHandler() { CookieContainer = cookieContainer })
using (var client = new HttpClient(handler) { BaseAddress = baseAddress })
{
// some defaults, add a header and cookie for authenticating with the API
client.DefaultRequestHeaders.Add("User-Agent", USER_AGENT);
client.DefaultRequestHeaders.Add("X-AvoSig", AvoSignature);
cookieContainer.Add(baseAddress, new Cookie(COOKIE_NAME, CookieValue));
// Post the content and return the result
var uri = new Uri(API_URL_MEDIA);
var content = new MultipartFormDataContent();
content.Add(new StringContent(caption), ""caption"");
var t = new StreamContent(photoContents);
t.Headers.ContentType
= new System.Net.Http.Headers.MediaTypeHeaderValue(contentType);
fileName = string.IsNullOrEmpty(fileName) ? ""img.png"" : fileName;
content.Add(t, ""media"", """ + fileName + """);
var response = PostBuffer(uri, content);
response.EnsureSuccessStatusCode();
public void AddPhoto()
{
DispatcherHelper.CheckBeginInvokeOnUI(() => { PickPhoto(); });
}
// Create an OpenFilePicker starting in the pictures library, viewing thumbnails
var filePicker = new FileOpenPicker();
filePicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
filePicker.ViewMode = PickerViewMode.Thumbnail;
// Filter to include a sample subset of file types
filePicker.FileTypeFilter.Clear();
filePicker.FileTypeFilter.Add(".bmp");
filePicker.FileTypeFilter.Add(".png");
filePicker.FileTypeFilter.Add(".jpeg");
public string GetUsername()
{
var url = new Uri(API_URL_BASE);
var client = new HttpClient() { BaseAddress = url };
var response = client.GetAsync(url).Result;
response.EnsureSuccessStatusCode();
return response.Content.ReadAsStringAsync().Result;
}