Skip to content

Instantly share code, notes, and snippets.

View alexsorokoletov's full-sized avatar

Alex Sorokoletov alexsorokoletov

View GitHub Profile
@alexsorokoletov
alexsorokoletov / remove-bin-obj.sh
Last active October 1, 2019 12:13
Clear bin/obj folders for Xamarin projects, as well as other temporary Xamarin files. Developer lifesaver
#!/bin/bash
# based on http://stackoverflow.com/questions/755382/i-want-to-delete-all-bin-and-obj-folders-to-force-all-projects-to-rebuild-everyt
find . -iname "bin" -type d | xargs rm -rf
find . -iname "obj" -type d | xargs rm -rf
# clear VS4Mac temporary downloads
echo ~/Library/Caches/VisualStudio/7.0/TempDownload/
for f in ~/Library/Caches/VisualStudio/7.0/TempDownload/* ; do
sudo rm -rf $f
done
@alexsorokoletov
alexsorokoletov / uwp_image_convert_to_jpeg_quality.cs
Created May 23, 2016 02:03
How to convert image to JPEG and specify quality (q) parameter in UWP C# XAML
/// <summary>
/// Converts source image file to jpeg of defined quality (0.85)
/// </summary>
/// <param name="sourceFile">Source StorageFile</param>
/// <param name="outputFile">Target StorageFile</param>
/// <returns></returns>
private async Task<StorageFile> ConvertImageToJpegAsync(StorageFile sourceFile, StorageFile outputFile)
{
//you can use WinRTXamlToolkit StorageItemExtensions.GetSizeAsync to get file size (if you already plugged this nuget in)
var sourceFileProperties = await sourceFile.GetBasicPropertiesAsync();
@alexsorokoletov
alexsorokoletov / uwp_image_resize.cs
Created May 23, 2016 01:49
How to resize image in UWP C# XAML
/// <summary>
/// Resizes and crops source file image so that resized image width/height are not larger than <param name="requestedMinSide"></param>
/// </summary>
/// <param name="sourceFile">Source StorageFile</param>
/// <param name="requestedMinSide">Width/Height of the output image</param>
/// <param name="resizedImageFile">Target StorageFile</param>
/// <returns></returns>
private async Task<IStorageFile> CreateThumbnaiImage(StorageFile sourceFile, int requestedMinSide, StorageFile resizedImageFile)
{
var imageStream = await sourceFile.OpenReadAsync();
@alexsorokoletov
alexsorokoletov / DC to Snowshoe ATT signal strength data.csv
Created January 4, 2016 22:02
This gist has CSV-formatted data about AT&T signal strength along the route from DC to Snowshoe, WV
datetime latitude longitude signal_strength
2016-01-03 18:33:12 +0000 38.40894761 -79.99546884 -88
2016-01-03 18:33:22 +0000 38.40841146 -79.99469443 -88
2016-01-03 18:33:32 +0000 38.40748744 -79.99485729 -76
2016-01-03 18:33:42 +0000 38.40637151 -79.99454096 -76
2016-01-03 18:33:52 +0000 38.40494671 -79.99430291 -119
2016-01-03 18:34:02 +0000 38.40346467 -79.99417358 -119
2016-01-03 18:34:12 +0000 38.40239375 -79.99459838 -119
2016-01-03 18:34:22 +0000 38.40129673 -79.99494128 0
2016-01-03 18:34:32 +0000 38.4002956 -79.99613319 0
@alexsorokoletov
alexsorokoletov / Helpers.sql
Last active February 9, 2022 08:00
Helpful functions when you need to find out what is going on on SQL Server
/* TOP SLOW REQUESTS */
/* time is in microseconds */
SELECT creation_time
,last_execution_time
,total_physical_reads
,total_logical_reads
,total_logical_writes
, execution_count
, total_worker_time
, total_elapsed_time
@alexsorokoletov
alexsorokoletov / CIEditorScript.cs
Created November 20, 2015 10:50
Unity3d automation script for Android and iOS
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
public class CIEditorScript
{
static string[] SCENES = FindEnabledEditorScenes ();
@alexsorokoletov
alexsorokoletov / custom.js
Created November 18, 2015 21:19
External links in menu fix - Ray Theme from ThemeForest http://themeforest.net/item/ray-app-responsive-wordpress-theme/9740730
//fix for external/custom links in menu
//for Ray Theme from ThemeForest http://themeforest.net/item/ray-app-responsive-wordpress-theme/9740730
//put that code to wp-content/themes/ray/assets/js/custom.js
//into nav function (around line 168)
$('.nav a.external').each(function(){this.href = this.href.substring(this.href.indexOf('#http')+1); });
@alexsorokoletov
alexsorokoletov / remove-itunesmetadata.sh
Created July 30, 2015 03:00
remove-itunesmetadata.sh
rm -rf ./temporarydir > /dev/null 2>&1
mkdir temporarydir
unzip $1 -d temporarydir
rm -rf ./temporarydir/Payload/*.app/iTunesMetadata.plist
rm -rf "$1.corrected.ipa"
pushd temporarydir
zip -r -X "../$1.corrected.ipa" .
popd
@alexsorokoletov
alexsorokoletov / vmpc.template.xml
Last active December 20, 2016 19:59
MvvmCross ViewModel Property Changed Xamarin Studio Snippet
<?xml version="1.0" encoding="utf-8"?>
<!-- copy to ~/Library/XamarinStudio-5.0/Snippets/ as vmpc.template.xml -->
<CodeTemplates version="3.0">
<CodeTemplate version="2.0">
<Header>
<_Group>C#</_Group>
<Version />
<MimeType>text/x-csharp</MimeType>
<Shortcut>vmpc</Shortcut>
<_Description>property changed</_Description>
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.Resources>
<local:ScrollToOpacityConverter x:Key="ScrollToOpacityConverter" />
<local:ScrollToMarginConverter x:Key="ScrollToMarginConverter" />
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>