Instantly share code, notes, and snippets.

mojeld mojeld

View GitHub Profile
@mojeld
mojeld / uwp_HttpClient.cpp
Created Aug 29, 2018
How to use the HttpClient class in Visual C++ 2017
View uwp_HttpClient.cpp
void cpp_uwp::json_test::Button_Click_1(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
using namespace Windows::Web::Http;
using namespace Windows::Storage::Streams;
ActivityIndicator1->IsActive = true;
IHttpClient^ NetHttp1 = ref new HttpClient();
concurrency::create_task(NetHttp1->GetAsync(ref new Uri("https://うあーるえる"))).then([this](IHttpResponseMessage^ res) {
concurrency::create_task(res->Content->ReadAsBufferAsync()).then([this](IBuffer^ buf) {
std::function<Platform::String ^ (std::string)> Utf8ToPlatformString{ [](std::string stin) {
@mojeld
mojeld / json_analyzer.cpp
Created Aug 28, 2018
JSON analysis with UWP VC++2017.
View json_analyzer.cpp
//
// JSON analysis using UWP's JsonObject
//
void cpp_uwp::json_test::Button_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
using namespace Windows::Data::Json;
std::function<void(JsonObject^)> hhge{ [this](JsonObject^ json1) {
std::wstringstream lout;
std::function<void(IJsonValue^, Platform::String^)> foo{
@mojeld
mojeld / rgb.ps1
Created Jul 24, 2018
PowerShell Color文字列 #000000をRGB分割してint型に変換表示
View rgb.ps1
<#
2018.07.24
PowerShell 色文字(#000000)からRGB分けてint変換
セキュリティがかかっている場合はSet-ExecutionPolicy RemoteSigned https://go.microsoft.com/fwlink/?LinkID=135170 を管理者モードで試す
PowerShellで rgb.ps1を実行した後、 > str_to_rgb -color "#00ff00"
#>
function global:str_to_rgb()
{
Param([string]$color)
View cs_Lambda_test.cs
//ラムダ式で渡すための宣言
public delegate void Proc<in T>(T arg1);
//ラムダ引数で渡す関数
private void Lambda_test(Proc<int> f)
{
for (int i = 0; i < 100; ++i)
{
f(i);
}
@mojeld
mojeld / Task_and_RunAsync_sample.cs
Created Jul 23, 2018
UWP - Task.Run()とDispatcher.RunAsync()を使ってasync/await
View Task_and_RunAsync_sample.cs
private async void Button_ClickAsync(object sender, RoutedEventArgs e)
{
p1.IsEnabled = true;
p1.IsIndeterminate = true;
t1.Text = "5000数えた後時間表示";
await Task.Run(async () =>
{
//何か重たい処理
for (int i = 0; i < 5000; ++i)
{
@mojeld
mojeld / holiday_lib.php
Created Apr 9, 2016
php 日本の休日判断
View holiday_lib.php
<?php
#//
#// 休日かどうかを判定
#//
function DateToHolidayBool( $date_str )
{
$date = strtotime( $date_str );
if( isWeekend( $date ) ){ return true; } // 土日判定
@mojeld
mojeld / uIOSUtils.pas
Created Jan 9, 2016 — forked from freeonterminate/uIOSUtils.pas
iOS のステータスバーの色を変える
View uIOSUtils.pas
unit uIOSUtils;
interface
uses
System.UITypes;
procedure SetStatusBarColor(const iColor: TAlphaColor);
implementation
@mojeld
mojeld / func.lua
Last active Aug 27, 2015
How to use lua53.dll in C++Builder
View func.lua
function lua_function_string(s)
return "るあ " .. s;
end
function lua_function_int(i)
return 5050 + i;
end
@mojeld
mojeld / ViewController_TextView.m
Last active Aug 29, 2015
"NSTextView" NSString, append it with a NSColor
View ViewController_TextView.m
//NSTextView 文字に色を付けてAppendする。
//Xcode6.3 MacOS
-(void)Append2:(NSString*)value1 lov:(NSTextView *)lov color:(NSColor*)cl
{
//dispatch_asyncブロック渡しする為?
dispatch_async(
//dispatch_get_main_queueメインのキューで処理
dispatch_get_main_queue(), ^{//^マークはブロック型(クロージャー)と言う事らしいです。
//↓attributeの入れ物を作る。
NSDictionary *satt = @{ NSForegroundColorAttributeName : cl};