View gist:8543d76561d522a45554a8d8a451149b
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void HAL_AFE_Init1MHZ_Clock(void){ | |
//RCC_AHB1PeriphClockCmd(HAL_DS_AFE_CLK1MHZ_PORT_GPIO_AHB_BIT, ENABLE); | |
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE); | |
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE); | |
GPIO_Init(HAL_DS_AFE_CLK1MHZ_PORT, (GPIO_InitTypeDef *) &HAL_DS_1MHz_CLK_GpioConfiguration); | |
GPIO_PinAFConfig(HAL_DS_AFE_CLK1MHZ_PORT, HAL_DS_AFE_CLK1MHZ_AF_PINSOURCE ,GPIO_AF_TIM2); | |
TIM_TimeBaseInitTypeDef TIM2_TimeBaseStructure; | |
TIM2_TimeBaseStructure.TIM_Period = 21; |
View element_template.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% with object.group_set.all|first as group %} | |
<li class="breadcrumb-item"><a href="{% url 'group_detail' group_id=view.kwargs.group_id %}">{{ group.name }}</a></li> | |
{% endwith %} |
View forms.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SimpleProjectModelChoicesField(ModelChoiceField): | |
def label_from_instance(self, obj): | |
return '{name}'.format(name=obj.name) | |
class CourseForm(ModelForm): | |
project = SimpleProjectModelChoicesField(queryset=Project.objects.filter(is_active=True)) | |
def __init__(self, *args, **kwargs): | |
self.request = kwargs.pop("request") |
View daysleft.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_getLeftActivationDays = (finishDate) => { | |
var endDate = new Date(finishDate); | |
var today = new Date(); | |
var oneDay = 24 * 60 * 60 * 1000; | |
return Math.round(Math.abs((today.getTime() - endDate.getTime())/ oneDay)); | |
} |
View serialloop.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
DEVICE=/dev/ttyUSB0 | |
BAUDRATE=230400 | |
echo "=======SETTINGS=========" | |
echo "port: $DEVICE" | |
echo "spped: $BAUDRATE" | |
echo "========================" |
View pylooper.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import serial | |
import time | |
def main(): | |
ser = serial.Serial('/dev/ttyUSB0', 230400, timeout=1) | |
print(ser.name) | |
count = 0 | |
while True: |
View gist:e928a619b3f0e4fe26f11872e8586653
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GPIO_InitTypeDef GPIO_I2CInitStructure; | |
/*Workaround p26 errata STM32F103*/ | |
__HAL_I2C_DISABLE(&hi2c1); | |
//OD HIGHG | |
GPIO_I2CInitStructure.Pin = I2C_SCL_PIN | I2C_SDA_PIN; | |
GPIO_I2CInitStructure.Mode = GPIO_MODE_OUTPUT_OD; | |
GPIO_I2CInitStructure.Pull = GPIO_PULLUP; | |
HAL_GPIO_Init(I2C_PORT, &GPIO_I2CInitStructure); | |
HAL_GPIO_WritePin(I2C_PORT, I2C_SCL_PIN, GPIO_PIN_SET); | |
HAL_GPIO_WritePin(I2C_PORT, I2C_SDA_PIN, GPIO_PIN_SET); |
View gist:8a6abcb121ad3049b84ea8bb3236a50b
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*ptr = '\n'; | |
ptr++; | |
*ptr = '\n'; | |
ptr++; | |
base = (PacketHdrBase*)ptr; |
View MapsActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Done in a MapFragment | |
@Override | |
public void onMapReady(GoogleMap googleMap) { | |
mMap = googleMap; | |
UiSettings mapUiSettings = mMap.getUiSettings(); | |
mapUiSettings.setCompassEnabled(false); | |
mapUiSettings.setZoomControlsEnabled(false); | |
mapUiSettings.setMapToolbarEnabled(false); | |
} |
View gzipsinkTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
public void testGzipSource() throws IOException { | |
String original = "Some super super long string.Some super super long string." + | |
"Some super super long string." + | |
"Some super super long string." + | |
"Some super super long string." + | |
"Some super super long string." + | |
"Some super super long string." + | |
"Some super super long string." + | |
"Some super super long string."; |
NewerOlder