Skip to content

Instantly share code, notes, and snippets.

View geapi's full-sized avatar

Georg Apitz geapi

View GitHub Profile
@geapi
geapi / no_teams.rb
Last active May 3, 2017 21:30
get repos with no associated teams for org, takes org as argument and expects github token in env var
require 'octokit'
class GithubCLI
# make sure to set your GITHUB_TOKEN in the environment
# also, the ocktokit gem needs to be installed
def get_repos_from_org_with_no_teams_assigned(github_org)
client = Octokit::Client.new :access_token => ENV['GITHUB_TOKEN']
client.auto_paginate = true
@geapi
geapi / TestSnippetPost.java
Last active November 18, 2016 19:38
example of using basic auth and csrf in RestTemplate call
package tips.cloudnative.todotest;
// imports
import static tips.cloudnative.testauthentication.TestAuthentication.csrfHeaders;
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class TodoTest {
@Test
@geapi
geapi / DevelopmentSecurityConfigWithCsrf.java
Created November 18, 2016 19:03
added Csrf tokenability to DevelopmentSecurityConfig
@Configuration
@Profile("development")
public class DevelopmentSecurityConfig extends WebSecurityConfigurerAdapter {
@Bean
public CsrfTokenRepository csrfTokenRepository() {
return CookieCsrfTokenRepository.withHttpOnlyFalse();
}
@Override
@geapi
geapi / TestAuthenticationWithCSRF.java
Last active November 18, 2016 18:59
added csrf tokens to the TestAuthentication
package tips.cloudnative.testauthentication;
import org.apache.commons.codec.binary.Base64;
import org.springframework.http.HttpHeaders;
public class TestAuthentication {
@Autowired
private CsrfTokenRepository csrfTokenRepository;
@geapi
geapi / TestSnippet.java
Last active November 18, 2016 19:14
example of using basic auth in RestTemplate call
package tips.cloudnative.todotest;
// imports
import static tips.cloudnative.testauthentication.TestAuthentication.basicAuthHeaders;
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class TodoTest {
@Test
@geapi
geapi / TestAuthentication.java
Last active November 18, 2016 19:02
Helper class that returns encoded basic auth header
package tips.cloudnative.testauthentication;
import org.apache.commons.codec.binary.Base64;
import org.springframework.http.HttpHeaders;
public class TestAuthentication {
public static HttpHeaders basicAuthHeaders() {
String plainCreds = "user:password";
byte[] plainCredsBytes = plainCreds.getBytes();
byte[] base64CredsBytes = Base64.encodeBase64(plainCredsBytes);
@geapi
geapi / DevelopmentSecurityConfig.java
Last active November 18, 2016 18:12
example SecurityConfig for Spring wit basic auth (locally)
// imports
@Configuration
@Profile("development")
public class DevelopmentSecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth
.inMemoryAuthentication()
@geapi
geapi / saveOnBlurTextMate2.md
Last active September 16, 2015 15:07
Setting save when focus lost in TextMate 2

###TextMate 2 save on focus lost create file .tm_properties in home folder and add saveOnBlur = true to it

mate $HOME/.tm_properties

and insert

saveOnBlur = true

@geapi
geapi / keymap.cson.md
Last active August 29, 2015 14:16
IntelliJ'esque keybindings for Atom (work in progress)

This gist has moved into a repo.

@geapi
geapi / bookmarklet.js
Last active April 1, 2016 21:44
Bookmarklet to show only the pipelines on your goCD dashboard/home that you decide to be there
/*
This snippet first unselects all pipelines and then adds the specified ones back.
USAGE:
replace YOUR_PIPELINE_NAME with actual value
in your browser create a bookmark to any URL
edit the bookmark, replacing the URL with snippet build from the below template
voila: when you are on the goCD dashboard; click it and all pipelines except yours should disappear
*/