Skip to content

Instantly share code, notes, and snippets.

@ksksue
ksksue / gist:4ec4ddd0a6d35215c30714681b44b535
Created March 21, 2019 02:14
非同期実行時にfunction内の引数が保持されるかの確認。結果保持される。
var state = 0;
function hoge(a) {
if(state === 0) {
setTimeout(function(){console.log(a);},1000);
} else {
setTimeout(function(){console.log(a);},500);
}
state++;
}
@ksksue
ksksue / c_cpp_properties.json
Last active October 10, 2018 16:27
VSCode c_cpp_properties.json for nRF5_SDK_15.2.0
{
"env": {
"gccArmPath": "/usr/local/gcc-arm-none-eabi-6-2017-q2-update",
"nrf5SdkPath": "~/Documents/Nordic/nRF5_SDK_15.2.0_9412b96"
},
"configurations": [{
"name": "Mac",
"includePath": [
"${gccArmPath}/arm-none-eabi/include",
"${gccArmPath}/arm-none-eabi/include/bits",
#include <MailCore/MailCore.h>
...
-(void) sendEmail:(NSString *) message
{
MCOSMTPSession *smtpSession = [[MCOSMTPSession alloc] init];
smtpSession.hostname = @"smtp.gmail.com"; // SMTPサーバのアドレス
smtpSession.port = 465;
smtpSession.username = @"moemoe"; // SMTPサーバのユーザ名
- (void)peripheral:(CBPeripheral *)peripheral didUpdateValueForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error
{
NSString* str = [[NSString alloc] initWithData:characteristic.value encoding:NSUTF8StringEncoding];
...
}
- (void)peripheral:(CBPeripheral *)peripheral didUpdateValueForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error
{
uint8_t *byte = (uint8_t *)[characteristic.value bytes];
...
}
#import <UIKit/UIKit.h>
#import "SKPSMTPMessage.h"
#import "NSData+Base64Additions.h"
@interface ViewController : UIViewController<SKPSMTPMessageDelegate>
@end
NSMutableData* data = [NSMutableData dataWithLength:sizeof(uint8_t) * 100];
uint8_t* array = [data mutableBytes];
/* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved.
*
* The information contained herein is property of Nordic Semiconductor ASA.
* Terms and conditions of usage are described in detail in NORDIC
* SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
*
* Licensees are granted free, non-transferable use of the information. NO
* WARRANTY of ANY KIND is provided. This heading must NOT be removed from
* the file.
*
int main(void)
{
// Initialize
leds_init();
timers_init();
buttons_init();
APP_GPIOTE_INIT(1);
uart_init();
ble_stack_init();
scheduler_init();
static void pstorage_test_store_and_load(void)
{
pstorage_handle_t handle;
pstorage_handle_t block_handle;
pstorage_module_param_t param;
uint8_t source_data[16] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F};
uint8_t source_data_2[16] = {0x00, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, 0x80, 0x90, 0xA0, 0xB0, 0xC0, 0xD0, 0xE0, 0xF0};
uint8_t dest_data[16] = {0};
uint32_t err_code;