Skip to content

Instantly share code, notes, and snippets.

@ostholz
ostholz / ExportToExcel
Created May 8, 2013 08:57
Apache POI Generate xls
public void exportToExcel(Window mainWindow){
//String title;
// String[] Headers TableColumnsDef. , Data, outputStream
HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet sheet = workbook.createSheet("Export");
// Header Style
HSSFCellStyle style = workbook.createCellStyle();
style.setFillForegroundColor(HSSFColor.SKY_BLUE.index);
style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
@ostholz
ostholz / NSStringConstant
Created June 21, 2013 10:59
Definition of a NSString constant
in .h
extern NSString *const name;
in .m
NSString *const name = @"Helle World";
@ostholz
ostholz / gist:5831587
Created June 21, 2013 14:34
AFNetwork download Progress
[op setDownloadProgressBlock:^(NSInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead) {
if (totalBytesExpectedToRead > 0) {
dispatch_async(dispatch_get_main_queue(), ^{
self.progressView.alpha = 1;
self.progressView.progress = (float)totalBytesRead / (float)totalBytesExpectedToRead;
NSString *label = [NSString stringWithFormat:@"Downloaded %lld of %lld bytes",
totalBytesRead,
totalBytesExpectedToRead];
self.progressLabel.text = label;
});
@ostholz
ostholz / gist:6413025
Created September 2, 2013 13:46
iOS System UIControls localization
in Info.plist
<key>CFBundleLocalizations</key>
<array>
<string>zh_CN</string>
<string>en</string>
<string>de</string>
</array>
@ostholz
ostholz / Get public ip
Created September 4, 2013 20:50
curl get public ip address
curl ifconfig.me
@ostholz
ostholz / Rails 4 Strong Parameters
Created February 3, 2014 08:38
Strong Parameter in Rails 4
def UsersController < ActionController::Base
def update
@user = current_user
if @user.update_attributes(user_profile_parameters)
redirect_to home_path, notice: "Your profile has been successfully updated."
else
render action: "edit"
end
end
@ostholz
ostholz / iOS 7 Hidden Statusbar
Last active August 29, 2015 14:05
iOS 7 UIStatusBarHidden
app.info_plist['UIViewControllerBasedStatusBarAppearance'] = false

Using Obj-C with MacRuby/Rubymotion

This little post aims to help you to translate Objective-C Blocks into Ruby blocks. Let's start by taking a look at few examples of iOS API call where blocks are used for animations and enumeration

Ruby Lambda Syntaxes:

Im Rubymotion and MacRuby you can use all the Ruby Lambda syntaxes that are:

block = lambda { |param|  ... }
@ostholz
ostholz / swift_standard_functions
Created October 20, 2014 10:19
Swift Standard Functions
abs(...)
advance(...)
alignof(...)
alignofValue(...)
assert(...)
bridgeFromObjectiveC(...)
bridgeFromObjectiveCUnconditional(...)
bridgeToObjectiveC(...)
bridgeToObjectiveCUnconditional(...)
c_malloc_size(...)
@ostholz
ostholz / JSF_Notiz
Created April 13, 2015 09:07
JSF Notiz
# load extern JavaScript File in xhtml
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
# loade local JavaScript File
<h:outputScript library="default" name="js/myJSFile.js"></h:outputScript>