Skip to content

Instantly share code, notes, and snippets.

View kendhia's full-sized avatar
💭
Loading...

Dhia Kennouche kendhia

💭
Loading...
View GitHub Profile
//[RENDER]
<TextInput
autoFocus={true}
onChangeText={value => this.changeKeyword(value)}
onSubmitEditing={event => {
this.changeKeyword(event.nativeEvent.text);
}}
style={{
padding: 0,
margin: 0,
@kendhia
kendhia / Kafka.txt
Last active April 6, 2020 18:41
Most used kafka commands
# number of messages in partitions of a topic
kafka-run-class.sh kafka.tools.GetOffsetShell --broker-list localhost:9092 --topic mytopic
# describe a topic
kafka-topics.sh --describe --zookeeper localhost:2181 --topic sales
## List and Describe groups
kafka-consumer-groups.sh --list --bootstrap-server localhost:9092
kafka-consumer-groups.sh --describe --group mygroup --bootstrap-server localhost:9092
@kendhia
kendhia / drawerState.js
Created January 28, 2020 07:50
Check state of Drawer of react nativagation
const parent = this.props.navigation.dangerouslyGetParent();
const isDrawerOpen = parent && parent.state && parent.state.isDrawerOpen;
if (isDrawerOpen) {
this.props.navigation.dispatch(DrawerActions.closeDrawer());
}
import React, {Component} from 'react';
import {
View,
Text,
StyleSheet,
Dimensions,
Image,
ImageBackground,
ScrollView,
import React, {Component} from 'react';
import {
View,
Text,
StyleSheet,
Image,
Dimensions,
TouchableOpacity,
} from 'react-native';
#include <msp430.h>
int main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
// If clock sig from mstr stays low, it is not yet in SPI mode
while (!(P1IN & BIT4));
P1SEL = BIT1 + BIT2 + BIT4;
P1SEL2 = BIT1 + BIT2 + BIT4;
UCA0CTL1 = UCSWRST; // **Put state machine in reset**
UCA0CTL0 |= UCCKPL + UCMSB + UCSYNC; // 3-pin, 8-bit SPI master
@kendhia
kendhia / master.c
Last active December 22, 2019 08:36
//Master device SPI code
#include <msp430.h>
unsigned char MST_Data, SLV_Data;
int main(void)
{
volatile unsigned int i;
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
P1OUT = 0x00; // P1 setup for LED & reset output
P1DIR |= BIT0 + BIT5; //
P1SEL = BIT1 + BIT2 + BIT4;
<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:tem=\"http://tempuri.org/\" xmlns:iot=\"http://schemas.datacontract.org/2004/07/IOTMobileWcfService\">\n" +
" <soapenv:Header/>\n" +
" <soapenv:Body>\n" +
" <tem:DevicePostData>\n" +
" <tem:data>\n" +
" <iot:deviceList>\n" +
" <!--Zero or more repetitions:-->\n" +
<iot:DeviceLists>\n" +
" <iot:accuracy>0</iot:accuracy>\n" +
" <iot:beaconId>%s:%s:%s</iot:beaconId>\n" +
* https://www.programiz.com/python-programming/datetime/strptime
* https://www.programiz.com/python-programming/datetime/strftime
const verifyColor = (a, alpha) => {
return /^((([A-Fa-f\d]){3}){1,2})$/.test(a) && Number(alpha)>= 0 && Number(alpha)<=1
}
const parseColor = (a) => {
if (a.length === 3){
const groups = /^([a-f\d]{1})([a-f\d]{1})([a-f\d]{1})$/i.exec(a)
return [parseInt(groups[1], 16)*17, parseInt(groups[2], 16)*17,parseInt(groups[3], 16)*17]
} else if (a.length === 6) {
const groups = /^([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(a)
return [parseInt(groups[1], 16), parseInt(groups[2], 16),parseInt(groups[3], 16)]