Skip to content

Instantly share code, notes, and snippets.

🎧
Learning to be a dad - contributions are limited at the moment

Xander Dumaine xdumaine

🎧
Learning to be a dad - contributions are limited at the moment
Block or report user

Report or block xdumaine

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@xdumaine
xdumaine / svgexport-rn.js
Created Nov 19, 2019
svg export for various react-native icon sizes
View svgexport-rn.js
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:"],
View nc-map.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View lazyload.js
/* 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 Jul 3, 2017
An svg of the webrtc logo, suitable for use as icon. Created "by eye" by Xander Dumaine
View webrtc.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View FizzBuzz.js
for(i=1;i<101;i++){r=i%3?'':'fizz';r+=i%5?'':'buzz';!r||console.log(r)}
View PostBuffer.cs
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
View MultipartFormDataContent.cs
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();
View AddPhoto.cs
public void AddPhoto()
{
DispatcherHelper.CheckBeginInvokeOnUI(() => { PickPhoto(); });
}
View OpenFilePicker.cs
// 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");
View async1.cs
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;
}
You can’t perform that action at this time.