Skip to content

Instantly share code, notes, and snippets.

View TyounanMOTI's full-sized avatar

Hirotoshi Yoshitaka TyounanMOTI

View GitHub Profile
@TyounanMOTI
TyounanMOTI / xcode-rstrip
Created December 4, 2010 14:26
rstrip and save script for Xcode
#!/usr/bin/ruby
require 'appscript'
output = String.new
$stdin.each_line do |line|
output << line.rstrip! + $/
end
document = Appscript.app('Xcode').text_documents.first
document.contents.set output
@TyounanMOTI
TyounanMOTI / esed
Created February 17, 2011 17:05
'sed -e' for each file. Output result for each file.
#!/bin/bash
# esed 's/foo/bar/g' files....
script=$1
shift 1
CHANGED=1 # diff returns 1 for differences. (0 for no difference, 2 for errors.)
for file in $*
do
sed -e ${script} ${file} > ${file}~
diff ${file} ${file}~ > /dev/null
#include <stdio.h>
int main( void ) {
double f = 5/2;
printf("%f\n", f);
}
@TyounanMOTI
TyounanMOTI / gist:1148992
Created August 16, 2011 12:47
Factory pattern with C++ template
#include <iostream>
#include <boost/shared_ptr.hpp>
template <class T>
class Engine
{
public:
virtual T Execute() = 0;
};
@TyounanMOTI
TyounanMOTI / gist:1297865
Created October 19, 2011 09:51
boost::multi_array vs Range based for loop
#include <gtest/gtest.h>
#include <boost/multi_array.hpp>
TEST(MultiArrayTest, Fill) {
boost::multi_array<int, 2> subject(boost::extents[20][10]);
for (auto x : subject) {
for (auto &y : x) {
y = 10;
}
}
@TyounanMOTI
TyounanMOTI / valarray_test.cpp
Created October 20, 2011 06:18
std::valarray initialization from raw pointer copies deeply.
#include <gtest/gtest.h>
#include <valarray>
TEST(ValarrayTest, InitializeWithRawPointer) {
int *p = (int*)malloc(sizeof(int)*10);
p[0] = 4;
ASSERT_EQ(4, p[0]);
std::valarray<int> subject(p, 10);
ASSERT_EQ(4, subject[0]);
#include <gtest/gtest.h>
enum {
CONSTRUCTOR,
COPY_CONSTRUCTOR,
};
class Bar
{
public:
@TyounanMOTI
TyounanMOTI / mac_build.patch
Created July 1, 2012 19:34
git diff --no-prefix 359e8fabadf696120b12d4c9428b34dd3527f2af > mac_build.patch
This file has been truncated, but you can view the full file.
diff --git libsrcs/angelscript/angelSVN/sdk/angelscript/projects/xcode/angelscript.xcodeproj/project.pbxproj libsrcs/angelscript/angelSVN/sdk/angelscript/projects/xcode/angelscript.xcodeproj/project.pbxproj
index 42aed37..b9daa61 100644
--- libsrcs/angelscript/angelSVN/sdk/angelscript/projects/xcode/angelscript.xcodeproj/project.pbxproj
+++ libsrcs/angelscript/angelSVN/sdk/angelscript/projects/xcode/angelscript.xcodeproj/project.pbxproj
@@ -1,512 +1,827 @@
-// !$*UTF8*$!
-{
- archiveVersion = 1;
- classes = {
- };
@TyounanMOTI
TyounanMOTI / mac_build.patch
Created July 3, 2012 09:26
git diff --no-prefix 359e8fabadf696120b12d4c9428b34dd3527f2af > mac_build.patch
This file has been truncated, but you can view the full file.
diff --git libsrcs/angelscript/angelSVN/sdk/angelscript/projects/xcode/angelscript.xcodeproj/project.pbxproj libsrcs/angelscript/angelSVN/sdk/angelscript/projects/xcode/angelscript.xcodeproj/project.pbxproj
index 42aed37..b9daa61 100644
--- libsrcs/angelscript/angelSVN/sdk/angelscript/projects/xcode/angelscript.xcodeproj/project.pbxproj
+++ libsrcs/angelscript/angelSVN/sdk/angelscript/projects/xcode/angelscript.xcodeproj/project.pbxproj
@@ -1,512 +1,827 @@
-// !$*UTF8*$!
-{
- archiveVersion = 1;
- classes = {
- };
@TyounanMOTI
TyounanMOTI / mac_build.patch
Created July 3, 2012 09:32
git diff --no-prefix 359e8fabadf696120b12d4c9428b34dd3527f2af > mac_build.patch
This file has been truncated, but you can view the full file.
diff --git libsrcs/angelscript/angelSVN/sdk/angelscript/projects/xcode/angelscript.xcodeproj/project.pbxproj libsrcs/angelscript/angelSVN/sdk/angelscript/projects/xcode/angelscript.xcodeproj/project.pbxproj
index 42aed37..b9daa61 100644
--- libsrcs/angelscript/angelSVN/sdk/angelscript/projects/xcode/angelscript.xcodeproj/project.pbxproj
+++ libsrcs/angelscript/angelSVN/sdk/angelscript/projects/xcode/angelscript.xcodeproj/project.pbxproj
@@ -1,512 +1,827 @@
-// !$*UTF8*$!
-{
- archiveVersion = 1;
- classes = {
- };