Skip to content

Instantly share code, notes, and snippets.

View dwelch2344's full-sized avatar

David Welch dwelch2344

View GitHub Profile
SSID BSSID RSSI CHANNEL HT CC SECURITY (auth/unicast/group)
CenturyLink7173 fe:f5:28:2b:7f:40 -83 9,-1 Y US WPA(PSK/TKIP,AES/TKIP) WPA2(PSK/TKIP,AES/TKIP)
Holms01 40:4a:03:df:d3:77 -88 3 N -- WPA(PSK/AES,TKIP/TKIP) WPA2(PSK/AES,TKIP/TKIP)
@dwelch2344
dwelch2344 / encrypt.sh
Last active August 29, 2015 14:06
OpenSSL RSA cert + private key encryption of files locally
# Generate our cert and key
openssl req -x509 -days 10000 -newkey rsa:2048 -keyout key.pem -out setup.crt -subj '/'
# Strip the password off the key
openssl rsa -in key.pem -out key.pem
# Encrypt our file
openssl smime -encrypt -aes256 -binary -outform PEM -in file.txt -out file.aes setup.crt
# Decrypt our file
openssl smime -decrypt -inform PEM -binary -in file.aes -inkey key.pem -out decrypted.txt
@dwelch2344
dwelch2344 / BatchRequestController.java
Last active August 29, 2015 14:03
An example of BatchController's request and responses.
@RestController
@RequestMapping("/$batch")
public class BatchRequestController {
@Inject
private List<RequestMappingHandlerMapping> mappings;
@Inject
private List<HandlerAdapter> handlerAdapters;
@Configuration
public class SampleConfig<T> {
@Bean
public Service<T> service(){
return new Service<T>(repo());
}
@Bean
public Repository<T> repo(){
@dwelch2344
dwelch2344 / Consumer.java
Created April 29, 2014 17:00
While reading a few great articles (http://www.intertech.com/Blog/spring-4-generic-qualifiers/ comes to mind) I noticed that Spring 4 supports injecting generic objects if their type is provided when defining @beans. I'm trying to figure out how I can do that when describing beans in a BeanDefinitionRegistryPostProcessor
public class Consumer{
// these work with qualifiers...
@Inject
private GenericService<User, Long> userService;
@Inject
private GenericService<Organization, Long> orgService;
}
@Component
public class Foo extends InstantiationAwareBeanPostProcessorAdapter implements BeanDefinitionRegistryPostProcessor {
@Override
public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry defRegistry) throws BeansException {
DefaultListableBeanFactory registry = (DefaultListableBeanFactory) defRegistry;
Map<String,JpaRepository> repos = registry.getBeansOfType(JpaRepository.class);
// Repos is always empty :(
Set<Class<?>> entities = new Reflections("com.example").getTypesAnnotatedWith(Entity.class);
for(Class<?> entity : entities){
@dwelch2344
dwelch2344 / 1_note.md
Last active August 29, 2015 13:57
HATEOAS doesn't search base classes annotations. See 1_note.md

Notice AbstractResourceController has the actual lookup methods (all of which work). But when an AbstractAssembler implementation builds the links, we don't get the Controller's base URL appended (compare theoutput.json's self vs address ref)

@dwelch2344
dwelch2344 / gulp-flat-copy.js
Created February 13, 2014 04:23
A simple GulpJS plugin for copying resources into a specific folder (and not retaining their previous path)
var path = require('path');
var through = require('through');
var File = require('gulp-util').File;
module.exports = function(){
var files = [];
function onStream(file){
files.push(file);
}
@dwelch2344
dwelch2344 / dwelch.zsh-theme
Last active January 4, 2016 07:38
A placeholder for my coming build script... a oh-my-zsh theme
function git_prompt_info() {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
echo "$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_PREFIX$(current_branch)$ZSH_THEME_GIT_PROMPT_SUFFIX"
}
function get_pwd() {
print -D $PWD
}
function battery_charge() {
@dwelch2344
dwelch2344 / angular-jquery-colorpicker.js
Created January 14, 2014 04:16
A sample of a colorPicker directive that utilizes jQuery (but plays nice with Angular)
app.directive('colorPicker', function() {
return {
scope: {
color: '=colorPicker'
},
link: function(scope, element, attrs) {
element.colorPicker({
// initialize the color to the color on the scope
pickerDefault: scope.color,
// update the scope whenever we pick a new color