Skip to content

Instantly share code, notes, and snippets.

View YoungjaeKim's full-sized avatar

YoungjaeKim YoungjaeKim

View GitHub Profile
@YoungjaeKim
YoungjaeKim / TelerikUserStore.cs
Last active August 29, 2015 14:05
ASP.NET UserStore for Telerik DataAccess
/// <summary>
/// UserStore for Telerik DataAccess.
/// </summary>
public class TelerikUserStore : IUserStore<AspNetUser, int>, IUserPasswordStore<AspNetUser, int>, IUserClaimStore<AspNetUser, int>,
IUserRoleStore<AspNetUser, int>, IUserSecurityStampStore<AspNetUser, int>, IUserLoginStore<AspNetUser, int>, IUserLockoutStore<AspNetUser, int>,
IUserEmailStore<AspNetUser, int>, IUserPhoneNumberStore<AspNetUser, int>, IUserTwoFactorStore<AspNetUser, int>
{
private bool _disposed;
public TelerikUserStore()
@YoungjaeKim
YoungjaeKim / installnet35.ps1
Created January 10, 2015 19:01
.NET Framework 3.5 Installation script for Azure Roles
# original: http://anuchandy.blogspot.kr/2014/06/automating-net-35-installation-on-azure.html
# Method that returns path to the directory holding 'installnet35.ps1' script.
function Get-ScriptDirectory
{
$Invocation = (Get-Variable MyInvocation -Scope 1).Value
Split-Path $Invocation.MyCommand.Path
}
# Gets path to the local resource we reserved for manipulating the zip file.
[void]([System.Reflection.Assembly]::LoadWithPartialName("Microsoft.WindowsAzure.ServiceRuntime"))
@YoungjaeKim
YoungjaeKim / installnet35.cmd
Last active August 29, 2015 14:13
.NET Framework 3.5 Installation cmdlet for Azure Roles
@echo off
reg query "HKLM\SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.5" /V SP
IF "%ERRORLEVEL%" EQU "0" (
ECHO dotnet framework 3.5 is already installed >> "%TEMP%\StartupLog.txt" 2>&1
EXIT 0
) ELSE (
PowerShell -ExecutionPolicy Unrestricted "%~dp0..\..\Startup\installnet35.ps1" >> "%TEMP%\StartupLog.txt" 2>&1
)
@YoungjaeKim
YoungjaeKim / ServiceDefinition.csdef
Last active August 29, 2015 14:13
A portion of ServiceDefinition.csdef file for .Net Framework installation during Azure Role startup
<Task commandLine="Startup\installnet35.cmd" executionContext="elevated" taskType="simple">
<Environment>
<Variable name="EMULATED">
<RoleInstanceValue xpath="/RoleEnvironment/Deployment/@emulated" />
</Variable>
</Environment>
</Task>
@YoungjaeKim
YoungjaeKim / Text.java
Created May 12, 2013 15:28
기록물 시간 표시에 사용되는 친숙한 시간 표현 변환. 최적화 덜 됨.
/**
* 친숙한 시간 표기법.
* @param date 과거시간데이터.
* @return 한국어로 친숙한 시간 설명 출력.
* @exception 미래값을 넣으면 {@link IllegalArgumentException} 발생.
*/
public static String toFriendlyDateTimeString(DateTime date){
DateTime now = new DateTime();
if (date.isAfterNow())
throw new IllegalArgumentException("Future DateTime cannot be not handled.");
@YoungjaeKim
YoungjaeKim / QuestionViewActivity.java
Created May 12, 2013 15:27
ActionMode on ActionBarSherlock. A kind of context menu.
private final class ActionModeForReply implements ActionMode.Callback {
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
//Used to put dark icons on light action bar
menu.add(R.string.send_now)
.setIcon(R.drawable.ic_menu_send_now)
.setShowAsAction(MenuItem.SHOW_AS_ACTION_WITH_TEXT | MenuItem.SHOW_AS_ACTION_ALWAYS);
return true;
@YoungjaeKim
YoungjaeKim / NullableBooleanToVisibilityConverter.cs
Created June 10, 2013 18:23
More usable Boolean to Visibility converter for XAML converter
public class NullableBooleanToVisibilityConverter : IValueConverter
{
/// <summary>
/// Converts a value.
/// </summary>
/// <returns>
/// A converted value. If the method returns null, the valid null value is used.
/// </returns>
/// <param name="value">The value produced by the binding source.</param>
/// <param name="targetType">The type of the binding target property.</param>
@YoungjaeKim
YoungjaeKim / InverseBooleanConverter.cs
Created June 11, 2013 03:22
Inversed Boolean Converter for XAML.
public class InverseBooleanConverter : IValueConverter
{
/// <summary>
/// Converts a Boolean value as inversed.
/// </summary>
/// <returns>
/// A converted value. If the method returns null, the valid null value is used.
/// </returns>
/// <param name="value">The value produced by the binding source.</param>
@YoungjaeKim
YoungjaeKim / ZumoPush.java
Last active December 18, 2015 09:09
Azure Mobile Service push notification for Android (or Java).
private class PushAsyncTask extends AsyncTask<Void, Void, Void>{
protected Void doInBackground(Void... voids) {
HttpPost httpPost = new HttpPost("https://<DOMAIN>.azure-mobile.net/tables/<TABLE-NAME>");
httpPost.setHeader("Accept", "application/json");
httpPost.setHeader("Content-type", "application/json");
httpPost.setHeader("X-ZUMO-APPLICATION", "YOUR-AZURE-MOBILESERVICE-KEY-IS-HERE");
JSONObject jsonObject = new JSONObject();
try {
@YoungjaeKim
YoungjaeKim / zumo_server_script.java
Last active December 18, 2015 09:09
Azure Mobile Service server-side script.
function insert(item, user, request) {
request.execute({
success: function() {
// Write to the response and then send the notification in the background
request.respond();
if(item.platform == "ANDROID") {
push.gcm.send(item.channel, item.text, {
success: function(response) {
console.log('Push sent: ', item.channel, response, 'time: ', new Date());
}, error: function(error) {