Skip to content

Instantly share code, notes, and snippets.

Batuhan Bayrakci baybatu

View GitHub Profile
@rednaxelafx
rednaxelafx / demo.groovy
Created Apr 6, 2011
get properties from an object in Groovy, even when the object has an getProperties() method
View demo.groovy
def getPropertiesFrom(obj) {
obj.metaClass.properties.findAll { it.name != 'class' && it.name != 'metaClass' }.inject([:]) { acc, e -> acc[e.name] = e.getProperty(obj); acc }
}
class Foo {
int getBar() { 42; }
List getProperties() { [] }
}
def foo = new Foo();
foo.properties; //=> []
@jlong
jlong / uri.js
Created Apr 20, 2012
URI Parsing with Javascript
View uri.js
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
View gist:4dc603b56399918bfb54
import re
import csv
import urllib
class Parse:
params = re.compile('(?P<key>[\S]*)=\{(?P<value>[\S]*)\}')
prep = re.compile('(?P<key>[\S]*)=(?P<value>[\S]*)')
@ufuk
ufuk / BaseMockitoTest.java
Last active Apr 9, 2019
Performs "verify no more interactions" check automatically for all mock objects (works with Mockito version 2). For detailed description: https://ufukuzun.wordpress.com/2019/04/09/ne-olup-bittiginden-habersiz-testlere-derman-mockscollector/ (Turkish)
View BaseMockitoTest.java
import org.apache.commons.lang3.ArrayUtils;
import org.junit.After;
import org.junit.runner.RunWith;
import org.mockito.InOrder;
import org.mockito.runners.MockitoJUnitRunner;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.verifyNoMoreInteractions;
@RunWith(MockitoJUnitRunner.class)
@joemiller
joemiller / clone-all.sh
Last active Mar 4, 2019
clone all repos from an org, including private repos
View clone-all.sh
#!/bin/sh
# Reqs: curl, ruby, git
#
# TOKEN: Create a personal access token here: https://github.com/settings/tokens
#
# Usage:
#
# To clone all repos from $ORG into current directory:
#
# $ curl https://gist.githubusercontent.com/joemiller/2dd72670e37769cb647c/raw | TOKEN=<githubtoken> ORG=<orgname> bash
@jonikarppinen
jonikarppinen / Messages.java
Last active Apr 4, 2019
Example of using message resources in Spring Boot service layer code, in as simple way as possible (hopefully!)
View Messages.java
package com.company.project.components;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource;
import org.springframework.context.support.MessageSourceAccessor;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.util.Locale;
@ufuk
ufuk / HowToGetHttpServletRequestAndResponseProgrammatically.java
Created Oct 6, 2016
To get the request and response objects in Spring MVC projects you can use this code
View HowToGetHttpServletRequestAndResponseProgrammatically.java
ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.currentRequestAttributes();
HttpServletRequest httpServletRequest = servletRequestAttributes.getRequest();
HttpServletResponse httpServletResponse = servletRequestAttributes.getResponse();
@ufuk
ufuk / LazyDeveloper.java
Last active Aug 23, 2018
Just another reason to why you shouldn't use Lombok, in another saying another reason to why you should write unit tests: You have two fields in your class. Fields are in the same type. You use @AllArgsConstructor to auto-generate your all args constructor. It works for a moment, until you change the order of the field.
View LazyDeveloper.java
import lombok.AllArgsConstructor;
import lombok.Data;
@Data
@AllArgsConstructor
public class LazyDeveloper {
private String firstName;
private String lastName;
@ufuk
ufuk / StartEndTimeWithJodaTime.java
Created Oct 24, 2016
Joda-Time library provides us a Virtual Clock utility named "DateTimeUtils". This is a demonstration for mocking start-end times.
View StartEndTimeWithJodaTime.java
import org.joda.time.DateTime;
public class StartEndTimeWithJodaTime {
private DateTime startTime;
private DateTime endTime;
public void process() {
startTime = DateTime.now();
@livacengiz
livacengiz / detail.md
Last active Jul 30, 2018
Otomat Hackathon Detaylar
View detail.md

alt text

Nedir?

Creative coding (yaratıcı programlama) işlevsel olmasından çok yaratıcılığı ön plana çıkarmak için bilgisayar programları yazma işine verilen isimdir. Ortaya çıkan sonuçlar işitsel, görsel ya da başka herhangi bir formda olabilir.

Otomat, sürekli CRUD uygulamalar yapmaktan sıkılmış geliştiriciler olarak birlikte çok ilginç projeler geliştireceğimiz bir hackathon/creative coding partisi. 19-20 Kasım tarihlerinde (gece dahil) bir araya gelerek çok güzel görsel/işitsel ürünler üretip, çok güzel sohbetler edeceğiz.

Neler yapacağız?

Ne yapmak istiyorsanız! Yapılacak şey ve konu üzerine herhangi bir sınırlandırmamız yok. Ama etkinlik günü söyleyeceğimiz bazı teknik sınırlandırmalarımız olacak :) Bireysel olarak ya da grup olarak katılımak konusunda serbestsiniz. Hatta en güzeli herkesle yardımlaşmanız :)

You can’t perform that action at this time.