Rails3ã§Excelã§ä½ã£ãSJISã®CSVãã¡ã¤ã«ãUTF-8ã§èªã¿è¾¼ãæ¹æ³
2013/05/30 Rails3, Ruby 1.9.3-p125
Excelã§ä½ã£ãCSVã®èªã¿è¾¼ã¿æ¹æ³ãæ¢ãã¦ããããã®ãè¦ã¤ãããªãã£ãã
誰ãå°ã£ã¦ãªãã®ããªããæ°ã«å
¥ãã®ãã¤ãä½ãã
éç¨
ã¾ãã試è¡é¯èª¤ãã¦ãæä¸ã®ãã¤ãè¼ãããExcelã§ä½ã£ãCSVã¯SJISã¨ãã¦ä¿åãããã
DBã¯UTF-8ãªã®ã§å¤æããªãã¦ã¯ãããªãã
CSV.foreach(filename, encoding: "Shift_JIS:UTF-8") do |row| # ⦠end
ArgumentError: invalid byte sequence in UTF-8
ã§å¼ã£ãããã¾ããã
æªå®ç¾©æåãããã¨ãerrorã«ãªãããã ï¼
open()ã使ã£ã¦ããã¾ãããã£ã¦ãããã©ã
Webã§open()ã¨ãææçã§ä½¿ããªãã(調ã¹ã¦ãªãã ããã ãã©ã)
SJISã§èªã¿è¾¼ãã§ãUTF-8ã«å¤æãã¦ãããã¨ã«ããã
CSV.foreach(filename, encoding: "SJIS") do |row| new_hash = row.to_hash row = Hash[new_hash.map { |k,v| k, v.encode("UTF-16BE", :invalid => :replace, :undef => :replace, :replace => '?').encode("UTF-8")] }] end
ããã§ãã
ArgumentError: invalid byte sequence in UTF-8
ã¨åºããããã
çµç«¯æåãæªãããã¦ããããã ãExcelã®çµç«¯æåã¯"\r\n"ã«ãªãã¿ããã§ãã
row_sep: "\r\n"
ã追å ãããã¨ã«ãããã¨ã§ç´ã£ãã
çµæ
çµæã¯ãããªãã¾ããã
CSV.foreach(filename, headers: true, row_sep: "\r\n", encoding: "SJIS") do |row| new_hash = row.to_hash row = Hash[new_hash.map { |k,v| k, v.encode("UTF-16BE", :invalid => :replace, :undef => :replace, :replace => '?').encode("UTF-8")] }] Products.new(row).save! end
ããããredmineã§ãCSVèªã¿è¾¼ãããããªãã½ã¼ã¹èªãã§ã¿ããã
gitããããªãè¦ãããã¨ãã人ã®çåããããè¼ãã¦ã
2013/05/22 git
ãããªããã¼ã¸ã§ã³ç®¡çãã¼ã«ã«è§¦ãã¦ãgitãç解ãããã¨ãã¦ã人ã«é¢ãããããããæãã¦ãã
æ°è»½ã«ç解ããã人åãã
ãgitã£ã¦githubã¨ãèããã¤?ã
æ®å¿µãªãããgitã¨githubã¯å¥ç©ã§ãã
gitã¯åæ£åãã¼ã¸ã§ã³ç®¡çãã¼ã«ã§ãã
github ã¯ã³ã¼ããgitãéãã¦å
±æãããå
¬éããããã®ãµã¼ãã¹ã§ãã
ãgithubãªãã¨git使ããªããã§ããï¼ã
ããããäºã«ãgitã¯ãã½ã³ã³1å°ããå§ããã¾ãã
github ã®ç»é²ã¯å¿
è¦ãªãã§ãããgit ã®ã¤ã³ã¹ãã¼ã«ã¯å¿
è¦ã§ãã
ãgitã¯è¤æ°äººã§svnã¯ï¼äººç¨ãªãã§ããï¼ã
ããããäºã«ãgitã¯ï¼äººã§ãè¤æ°äººã§ãå©ç¨ã§ãã¾ãã
ãè¤æ°äººã§ä½¿ãæ以å¤ã¯gitã¯å¿
è¦ãªããã§ããï¼ã
ããããäºã«ã1人ã§ãååå¹æçãª(ã³ã¼ã復å
ãªã©)使ãæ¹ãã§ãã¾ãã
ãã¾ãã¯ãGUIããå§ããããã§ããã©ã
æ®å¿µãªãããGUIã¯å¤§æµ git ãç解ãã¦ãã人åæã«ä½ããã¦ã¾ãã
GUIå°ç¨ç¨èªãå¢ãã¦æ··ä¹±ããå ´åãããã¾ãã
ãã³ãã³ãå¤ããã¦è¦ããããªãã
æ®å¿µãªãããèªç±åº¦ãåºããã¦å
¨é¨ã®ã³ãã³ããè¦ããã®ã¯é£ããã§ãã
ããããäºããæ¤ç´¢ããã®ãããã§ãã
ãcloneã¨ãno-ffã¨ãpushã¨ãpullã¨ãfetchã¨ãmergeã¨ãrebaseã¨ãã¨ããå
¨é¨è¦ããå¿
è¦ã¯ã»ã»ï¼ã
clone, push ã¯è¯ã使ãã¾ããããã以å¤ã¯ä»äººã®ã³ã¼ããæã£ã¦ãããããã¨ãã«å¿
è¦ã§ãã
å¿
è¦ãªã¨ãã«èª¿ã¹ã¦ä½¿ãã°ããã§ãããno-ff ã¯å
ã«èª¿ã¹ã¦è¿½å ããçãã¤ãã¦ããã¨ããããã§ãã
ãç¨èªãå¤ããã¦è¦ããããªãã
æ®å¿µãªãããèªç±åº¦ãåºããã¦å
¨é¨ã®ç¨èªãè¦ããã®ã¯é£ããã§ãã
ããªã¢ã¼ããªãã¸ããªãbranch, HEAD, ref, master, origin, bare...ã
ããããäºã«ãç¨èªãç¥ããªãã¦ã使ããã¨ã¯ã§ãã¾ããå¾ããç解ãã¦ãé
ãããã¾ããã
ãPUSHã¨ããããã©ãï¼äººéçºã®å ´åã¯ã©ãã«PUSHããã®ï¼ã
ï¼äººéçºã®å ´åã¯PUSHã¯ç¡ãã¦ããã¾ãã¾ããã
ãããªãã®æ¥å¸¸çã«ä½¿ãéè¦ãªã³ãã³ããããã¦ã
`git add -p' #å¤æ´ãç´°ãã追å
`git diff --cached' ##ä½ã追å ãããå¿ããã®ã§ç¢ºèª
`git commit -mã"fix typo username bug" ' #ç»é²ï¼ã³ãããï¼
ã®ã«ã¼ã
ãã®ä»ã¯åã®ãæ»ããããPUSHããããåããããã§ãããã ãã©ããã®ãã³ã«æ¤ç´¢
ãæä½æ¹æ³ã®å³ãã«ã¼ããã¦ãããã©ãã©ããããã¹ã¿ã¼ããªã®ï¼ã
åæå(init)ã¾ãã¯ã³ã¼ããæã£ã¦æ¥ã(clone)å¾ã¯ã`git add' ããå§ã¾ãã¾ãã
ãææ°ã®ä½¿ãæ¹ãè¦ããããã ãã©ã
git-flow ã§æ¤ç´¢ããã¨ã¹ãã¼ããªä½¿ãæ¹ãç¥ããã¨ãã§ãã¾ãã
ããã¾ã§ã
æ°ä»ããã追å ãã¦ãããããªã
Rubyã§èªã¿ãããããã¨ãã£ã¦ and 㨠or ãä»£å ¥(=)ã¨ä¸ç·ã«ä½¿ãã¨ããã«ããããã
ç°å¢:Ruby 1.9.3
Rubyã®æ¼ç®åã¨åªå
度ã®è©±ã§
åæ©çãªè©±ã ãã©è¦è½ã¨ãã¦ãããã¨ãæ¸ãã¾ãã
rubyã«ã¯ ã&&ãã||ã æ¼ç®åã®ä»ã«ãandããorããããã¾ãã
ããããã§ããããandã 㨠ãorã ã¯åªå
度ãåãã ãã©ã
ã&&ãã¯ã||ãããåªå
度ãé«ãã£ã¦ãã¤ããã
ãã®æç« ã¯ããè¦ãã
ã§ããæ°ãã¤ããªããã°ãããªãã®ã¯ãããä¸ã¤
ãandãã¨ãorãã¯ã=ãããåªå
度ãä½ããã¨ã
ã¾ãããandãã¨ã&&ãã¨ãã®æ¯è¼ãè¦ã¦ã¿ãã¨ã
irb> true || true && false #=> true irb> true or true and false #=> false irb> true || false && false #=> true irb> true or false and false #=> false
ã¨ããçµæã«ãªã£ã¦ã
irb> true || (true && false) #=> true irb> (true or true) and false #=> false irb> true || (false && false) #=> true irb> (true or false) and false #=> false
ãã解éãããã
åã解éãããã«ã¯ãæ¬å¼§ã§æ¬ã£ã¦ãã¾ãã°ããã®ã ã
irb> true || (true && false) #=> true irb> true or (true and false) #=> true irb> true || (false && false) #=> true irb> true or (false and false) #=> true
ãããããããä»£å ¥ãããã©ããªããã
æ°ãã¤ããã¹ãã¯ã
ãandãã¨ãorãã¯ã=ããããåªå
度ãä½ããã¨ã
ãããç¥ããªãã¨ãã£ã¨ããããããã¨ã«ãªãã
ãã£ãã®è§£éçµæããã®ã¾ã¾ä»£å
¥ãã¦ã¿ãã
irb> flag = true || (true && false) #=> true irb> flag #=> true irb> flag = true or (true and false) #=> true irb> flag #=> true irb> flag = true || (false && false) #=> true irb> flag #=> true irb> flag = true or (false and false) #=> true irb> flag #=> true
åããããªããã¨æã£ã¦ãã
irb> flag = "truedayo" and (true or false) #=> false irb> flag #=> "truedayo" irb> flag = "truedayo" && (true || false) #=> false irb> flag #=> false
ãªãã¨ãflag ã«ä¸é¨ã代å
¥ããã¦ãã¾ã£ãã
æ°ãã¤ããããã¨ãããã¨ã§ããã
ãandãã¨ãorãã®ä½¿ãéã¯ãä»£å ¥ç®çã§ä½¿ãã¨ããã®ãæ£ããã®ããªã
android mini PC ã® mk808 ã Windows7 㧠adb usb æ¥ç¶ã試ã
2012/02/10 ç°å¢ï¼Windows7 64 bit
android ã® miniPC mk808 ã¬ã¸ã§ãããã²ãããã¾ããã
MINI TV Dual-Core A9 Processor(ä¸å½è£½)ã¨ãæ¸ãã¦ã¾ãã
ãããarmãªãã§ããä¸æåã®ããã»ããµä¸¦ã®æ§è½ãããã¾ãï¼
PCå´ãã adb usb ã§ãããã°ãããã£ã¦ãã¨ããã¾ãããã
æå¤ã¨æããã£ãã®ã§æ¥½ã§ããããã«æé ãè¼ãã¾ãã
ãããã¨ã¯(å¾ã§è©³ç´°)ã
- Android SDKãæã«å ¥ããã
- SDK managerã§Google USB Driverãã¤ã³ã¹ãã¼ã«ãã
- androidããããã°ã¢ã¼ãã§æ¥ç¶ãã
- c:\user\ã¦ã¼ã¶å\.android\adb_usb.ini ã« ã0x2207ãã追è¨
- ããã¤ã¹ããã¼ã¸ã£ã§?ããã¤ã¹ã確èªãã¦VIDã¨PIDãåå¾
- android_winusb.infã«VIDã¨PIDã追è¨ãã
- ããã¤ã¹ããã¼ã¸ã£ã§ãã©ã¤ãã¤ã³ã¹ãã¼ã«
- adb kill-server&adb shell
ã¨ããæé ãããã£ã¦æ¥ãæ¹ã¯ããã§åããããªã
Android SDKãæã«å ¥ãã
ããã¯ã
Download Android Studio and SDK tools | Android Developers
ãããã¦ã³ãã¼ããã¦è§£å
Google USB Driverãåå¾
解åãããã©ã«ãã®ä¸ã®
SDK Manager.exe
ãå®è¡ãã¦Google USB Driverã«ãã§ãã¯ãã¤ãã¦ã¤ã³ã¹ãã¼ã«
Android ãããã°ã¢ã¼ãã§ã¤ãªã
ã¢ã³ããã¤ããç¹ãã§èµ·åãã¦ãã ããã
Androidã®ç»é¢ãã¿ã¦ãã ããã
- è¨å®ããUSBãé¸ãã§connect to PCã«ãã§ãã¯ãå ¥ãã
- developer setting ãããããã°ãªãã·ã§ã³ã«ãã§ãã¯ãå ¥ãã
- å³ä¸ã as media connected ãã USB debugging connectedã«å¤ããã°OK
0x2207ã®è¿½è¨
c:\user\ã¦ã¼ã¶å\.android\adb_usb.ini
ã«ãã¡ã¤ã«ãä½æãã¦ã0x2207ãã追è¨ãã
ããã¤ã¹ããã¼ã¸ã£ã§ãã©ã¤ãã®ã¤ã³ã¹ãã¼ã«
- ããã¤ã¹ããã¼ã¸ã£ãéãã¦ï¼ã®ããã¤ã¹ãæ¢ã
- å³ã¯ãªãã¯ããããã£â詳細ã®ãã¼ãã¦ã§ã¢ï¼©ï¼¤é ç®ãã¿ã
ããã«ã¯ãVIDã¨PIDãæ¸ããã¦ããã®ã§ã
adt-bundle-windows-x86_64\sdk\extras\google\usb_driverã®
android_winusb.infã«ä»¥ä¸ã追è¨
[Google.NTamd64] ;MK808 %SingleAdbInterface% = USB_Install, USB\VID_2207&PID_0006&REV_0222 %CompositeAdbInterface% = USB_Install, USB\VID_2207&PID_0006
VIDã¨PIDã¯åèªå¤æ´ã«ãªãããããã¾ããã
ããã¤ã¹ããã¼ã¸ã£ãéãã¦ï¼ããã¤ã¹ã®ã¤ã³ã¹ãã¼ã«ãé¸ã¶
ãã©ã¤ãã¼ã½ããã®åç
§å
ã«
adt-bundle-windows-x86_64\sdk\extras\google\usb_driver
ãé¸æããã¨ã¤ã³ã¹ãã¼ã«ãå®äºããã
å®äº
adb kill-server adb shell
ããã¦è¡¨ç¤ºã§ããã°å®äºã§ãã
ãã¨ãã³ãã³ãããã³ããã§æä½ããã®ã¯é£ããã®ã§ãadb æ¥ç¶ãã§ãã
puttyæ¹è¯çãè¼ãã¦ããã¾ãã
http://forum.xda-developers.com/showthread.php?t=803225
ããã§Tabè£å®ã¨ããã§ããããã«ãªãã¾ãã
åè
jikiba の 備忘録 / memorandum book by jikiba MK808 その1 ADB 接続
おっさんエンジニアの実験室: MK808でadbが出来るまでの長い道のり
p {:key => 123} ãåããªãããã§Rubyãå°ãå«ãã«ãªã£ã
ãããäºç´°ãªãã¨ãããããªãã§ãã
ããã·ã¥ãç´æ¥outputããã¨ã¨ã©ã¼ãåºãã
[10] pry(main)> p {:key => 123} SyntaxError: unexpected tASSOC, expecting '}' p {:key => 123}
ä»£å ¥å¾ã ã¨ã¡ããã¨åãããªã«ãéããã ãã
[10] pry(main)> p h = {:key => 123} {:key=>123} => nil
ã¡ãªã¿ã«é åã ã¨åé¡ãªã
[11] pry(main)> p [1,2,3,4,5] [1, 2, 3, 4, 5] => nil
ãããã¯ã®{}ã¨ãåãã ãã解éã§ããªãã£ã¦çç±ã ãããã©ã
ããã©ã¼ãã³ã¹ã®åé¡ãªã®ãï¼
妥åãããããªãã®ããã
groongaåå¼·ä¼3ã§rroongaã使ã£ãæ¤ç´¢ãµã¼ãã¹ã®çºè¡¨ãã¦ãã[ãã³çª]
ã¦ã¿ãï¼ã§ãã
全文検索エンジンgroongaを囲む夕べ 3 @groonga : ATND
ã«è¡ã£ã¦çºè¡¨ããã¦ããã ãã¾ããã
çºè¡¨è³æã¯ããã§ãã
以åã®groongaåå¼·ä¼ã§ã¯ãgroongaæ¬ä½ã«ã¤ãã¦ã ã£ãã®ã§ããã
ä»åã¯ã¦ã¼ã¶ã®æ´»ç¨äºä¾ãã¡ã¤ã³ã«éããã¾ããã
åå¼·ä¼ã ããä½ãèããã«çºè¡¨ãã¾ã¼ãã£ã¨ãã£ã¦ã¿ããã
å®å¡150人ï¼ã¦ã¼ã¹ã200人ï¼ãã³ç400人ã§ããï¼
groonga大人æ°ï¼
ç§ã®çºè¡¨å
容ã¯ããrroongaã§çæ¾éã³ã¡ã³ããæ¤ç´¢ãã¦ã¿ããã§ããã
ãµã¼ãã¹ã¯ニコ番ã§ãã
ä»åã¯çæ¾éã³ã¡ã³ãã¨ãã¦ããã³ãã³ã¦ã¼ã¶ã¼çæ¾éã対象ã¨ãã¾ããã
æåãããã³ãã³çæ¾éãå©ç¨ãã¦ããªãæ¹ã«ã¯ã
ããããããå
容ã«ãªã£ã¦ãã¾ã£ãã¨åçãã
ããã§ãè¨ãããã£ããã¨ã¨ãã¦ã¯ã
rroongaã¯ãçæ¾éã®ãããªã³ã¡ã³ããã©ãã©ãæ¸ãè¾¼ã¾ããç¶æ³ã§ãã
å³åº§ã«ãã¼ã¿ãã¼ã¹ã«åæ ããããã°ããæ¤ç´¢ã§ãããã¨ã§ãã
ãã£ã¦ã¿ã¦ã¤ã¾ãããããªã¨ããã¯ããããçãè¾¼ãã ã¤ããã§ãã
Railsã¨ã®é£æºå³ã¨ããè¼ãã¦ã¿ãã®ã§ããåèã«ãªã£ãã§ããããã
æ親ä¼ã«ãåå ããã¦ããã ãã¾ããã
milkodeã®ã¹ãã¼ã«ã¼ï¼ããããããã
数万のソースコードから目的の一行を一瞬で見つけ出す、Milkode - ブログのおんがえし
è¦å´è£è©±ãªã©ãèãã¾ããheheheï¼
æ°ããªãä»äºãã£ã³ã¹ããããªã¨ããï¾ï½¸ï¾ï½¸ã ã£ãããã¨ã£ã¦ã楽ããã£ãã§ãï¼
ã¾ãåå ãããã§ããï¼
ãã³ãã³çæ¾éã®ä¾¿å©ãã¼ã«ä½ã£ã¦ã¿ãã[ãã³ãã³ã¼ã«ï¼Zero]
ãã³ãã³ã¦ã¼ã¶çæ¾é便å©ãã¼ã«ä½ã£ã¦ã¿ãã®ã§ã¡ãã£ã¨ç´¹ä»ãã¾ãã
ãã³ãã³ã¼ã«ï¼Zero && Nicoban ã®äºã¤ã®ãµã¼ãã¹ãä¸ç·ã«ãªãã¾ããã
ãã³ãã³ã¼ã«ï¼Zeroã£ã¦ãªã«ï¼
次æ 移åç¨ã®ã¦ã¼ã¶æ¾éæ°çéç¥ãã¼ã«ããã³ãã³ã¢ã©ã¼ãã®ãããªç©
ç¹å¾´ï¼ãã¹ã ã¼ãºãªæ¬¡æ 移åãã³ã³ã»ããã
ã¤ã³ã¹ãã¼ã«ãªãï¼ãã©ã¦ã¶ã®ã¿ï¼ã§Macã§ã使ãã¦ç°¡åããã³ãã³ã¼ã«ï¼Zero ã¯å¾
æ©ãã¦ãããã³ãã³ã®çæ¾éããã£ãå ´åã«æ¬¡æ ã¸èªå°ãã¦ããããã¼ã«ã§ããéç¥ã¯ããã·ã¥é
ä¿¡ã«å¯¾å¿ãã¦ããã®ã§æ´æ°ãã¿ã³ãé£æããå¿
è¦ãç¡ããªãã¾ãã
å ¬å¼ãã³çã¢ã©ã¼ãããããã©ï¼ãã³ãã¥ããã£ã«å ¥ããã次æ ã§æ±ºããã¨ãã¨ãã«ä½¿ããããã©ã¦ã¶ã®ç»é¢ã«è¡¨ç¤ºãããã®ã§æ°ã¥ãããããç主ã¯åæ ã§ãç¥ããããã¨æ¬¡æ ã¸èªããããã§ãã
ãã©ã¦ã¶ã ã£ããéç¥ã¾ã§ã«ã©ã°ãããããããªãã®ï¼ãä¸å®æéãã¨ã«æ´æ°ãããããã§ã¯ãªããæ¾éãéå§ãããã¿ã¤ãã³ã°ã§éç¥ããã¾ãã
使ãæ¹
å°å
¥
ã¤ã³ã¹ãã¼ã«ãªã©ã¯å¿ è¦ããã¾ãããä¸ã®ï¼µï¼²ï¼¬ã«ã¢ã¯ã»ã¹ãã¦ãã ããã
ニコニコール http://niconama.temita.net/niconicall
ç主ã®æ¹ã¯ãhttp://niconama.temita.net/niconicall?co6155(âã³ãã¥id)ãã®ãªã³ã¯ãå¼µãã°èªåçã«æ¬¡æ å¾ ã¡ã«ãªãã¾ãã
å®ã¯ãããï¼ä»£ç®(d:id:temita:20090430)ã§ãã以åã«å ¬éãã¦ï¼æ¥ã§ãµã¼ãã¹çµäºãä½åãªããããã®ã復活ããã¾ãããä»åã¯ããã·ã¥é ä¿¡ãèªåã§ç¨æãããªã©ãã¯ã¼ã¢ãããã¦ã¾ããæè¡çãªè©±ãæ¸ãã¦ãããããªã
Nicoban ã«ã¤ãã¦ã¯ã®ã¡ã»ã©ç´¹ä»ãã¾ãããã£ã¡ã®æ¹ãããã°ã£ã¦ããããã