Skip to content

Instantly share code, notes, and snippets.

View mcroteau's full-sized avatar

Mike Croteau mcroteau

View GitHub Profile
@aslamanver
aslamanver / main_screen.dart
Created October 3, 2019 11:09
Flutter custom inheritance - Extending the base class
import 'package:flutter/material.dart';
class MainScreen extends StatefulWidget {
@override
_MainScreenState createState() => _MainScreenState();
}
class _MainScreenState extends _BaseStatefulState<MainScreen> {
@override
Widget build(BuildContext context) {
@lovubuntu
lovubuntu / Sha256.kt
Created November 24, 2017 15:58
function to generate Sha-256 in Kotlin
Class Hasher {
fun hash(): String {
val bytes = this.toString().toByteArray()
val md = MessageDigest.getInstance("SHA-256")
val digest = md.digest(bytes)
return digest.fold("", { str, it -> str + "%02x".format(it) })
}
}
@JensWalter
JensWalter / FormDataHandler.java
Created October 10, 2015 19:02
FormDataHandler for com.sun.net.httpserver.HttpHandler
package io.trivium.glue.binding.http;
import com.sun.net.httpserver.Headers;
import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpHandler;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.Charset;
@genediazjr
genediazjr / Add-CORS-Filter-to-Spring Maven.xml
Last active June 19, 2020 09:53
Add CORS Filter to Spring Maven
<!-- Append to pom.xml -->
<dependency>
<groupId>com.thetransactioncompany</groupId>
<artifactId>cors-filter</artifactId>
<version>1.8</version>
</dependency>
<!-- Append to web.xml -->
<filter>
@naaman
naaman / gist:1053217
Created June 29, 2011 05:33
Hot Swapping With Maven, Jetty and IntelliJ

Hot Swapping With Maven, Jetty and IntelliJ

Based on Configuring Jetty, Maven, and Eclipse together with Hot Swap

I've always been a bit jealous when it comes to the Play! framework and the great dev mode they have for hot swapping classes at runtime. Jetty has a configuration setting, scanIntervalSeconds, that mimics this when working with a more traditional WAR, but does so by looking for changes to a file and restarting the server.

Fortunately, Jetty also provides the ability to rapidly test code with hot swapping. No more server restarts. The trick to getting hot swapping to work is to attach a remote debugger to your Jetty process. The following instructions outline how to do this in IntelliJ (tested with IDEA 10.5 CE).

Modify your jetty-maven-plugin to ignore the scan interval

  1. Open your pom and locate the plugins section
@SimonCropp
SimonCropp / ClientConsole
Created May 19, 2011 02:34
non blocking client server with httplistener
using System;
using System.Net;
using System.Threading;
using System.Threading.Tasks;
namespace ClientConsole
{
static class Program
{