Skip to content

Instantly share code, notes, and snippets.

Fabian Hurnaus fahu

Block or report user

Report or block fahu

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@fahu
fahu / gist:4517103b7da93aec9dcc1c5baf935364
Created Oct 31, 2017
gitignore for web projects with IntelliJ IDEA Ultimate 2017
View gist:4517103b7da93aec9dcc1c5baf935364
# IntelliJ IDEA Ultimate 2017
## User-specific stuff:
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/dictionaries
@fahu
fahu / CreateShipment.php
Last active Jul 16, 2018
How to create a shipment programmatically in Magento 2
View CreateShipment.php
<?php
class CreateShipment extends \Magento\Backend\App\Action
{
/**
* The OrderRepository is used to load, save and delete orders.
*
* @var \Magento\Sales\Model\OrderRepository
*/
protected $orderRepository;
@fahu
fahu / Uint8ArrayUtils.ts
Last active May 30, 2017
Collection of often used @Uint8Array operations in Typescript
View Uint8ArrayUtils.ts
/**
* Collection of often used {Uint8Array} operations.
*/
class Uint8ArrayUtils {
/**
* Converts a 32 bit integer to an {Uint8Array}.
* @param int32 A 32 bit integer.
* @returns {Uint8Array} A {Uint8Array} containing the specified 32 bit integer.
*/
public static convertToByteArray(int32: number): Uint8Array {
@fahu
fahu / Crc16ItuCalculator.ts
Last active May 30, 2017
CRC16 ITU Typescript implementation
View Crc16ItuCalculator.ts
/**
* CRC16 ITU implementation for calculating a checksum of an {Uint8Array}.
*/
class Crc16ItuCalculator {
readonly CRC_16_TABLE = [
0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7,
0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef,
0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6,
0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de,
0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485,
@fahu
fahu / IntentTests.java
Created May 9, 2017
First time creating an Alexa Skill - Test Intent Snippet
View IntentTests.java
/**
* Basic implementation of a JUnit test to test an intent. The response of the intent is specified in a JSON file.
*/
@Test
public void testGetPetLocationIntent() throws Exception {
SpeechletResponse speechletResponse = SpeechletResponseTestUtils.getSpeechletResponse("where_is_my_dog.json");
PlainTextOutputSpeech outputSpeech = (PlainTextOutputSpeech)speechletResponse.getOutputSpeech();
assertNotNull(outputSpeech);
assertEquals("Your dog Bello is ...", outputSpeech.getText());
assertEquals("Your pets location", speechletResponse.getCard().getTitle());
@fahu
fahu / SpeechletResponseTestUtils.java
Created May 9, 2017
First time creating an Alexa Skill - SpeechletResponse from JSON Snippet
View SpeechletResponseTestUtils.java
/**
* This is a helper method which allows you to create a SpeechletResponse from the specified JSON file.
*
* @param requestFileName The name of the JSON file placed in your projects ressource/requests folder.
* @return The parsed SpeechletResponse from the specified JSON file.
*/
public static SpeechletResponse getSpeechletResponse(String requestFileName) throws Exception {
InputStream inputStream = getClass().getClassLoader().getResourceAsStream("requests/" + requestFileName);
SpeechletRequestEnvelope requestEnvelope = SpeechletRequestEnvelope.fromJson(inputStream);
IntentRequest intentRequest = (IntentRequest) requestEnvelope.getRequest();
@fahu
fahu / upload-skill-s3.sh
Created May 9, 2017
First time creating an Alexa Skill - Upload skill to S3 Snippet
View upload-skill-s3.sh
# Upload your archived alexa skill to S3.
aws lambda update-function-code --function-name arn:aws:lambda:eu-west-1:1234567890123:function:your-alexa-app --zip-file fileb://target/your-alexa-app-0.1-jar-with-dependencies.jar
@fahu
fahu / create-jar-archive.sh
Last active May 9, 2017
First time creating an Alexa Skill - Create JAR archive snippet
View create-jar-archive.sh
# Create a jar archive of your project
mvn assembly:assembly -DdescriptorId=jar-with-dependencies package
@fahu
fahu / 1-README.md
Last active May 9, 2017
lessons-learnt-alexa-blog-post
View 1-README.md

First time creating an Alexa Skill - Snippets

About it

This repository contains all the code snippet used in our blog post 'First time creating an Alexa skill — learn from our mistakes' which is published on Medium and fahu.at.

Links

Contributing

You like or dislike our blog post or would like to contribute to our post? Feel free to contact us (information in the Authors section)!

You can’t perform that action at this time.