Trying to open a .ks-ipc file but the file type doesn't seem to exist and Word opens a string of random characters. Does anyone know what this is? - file

I'm home sick and trying to view a worksheet my teacher posted to Canvas. The file is listed on Canvas as a .ks-ipc file, here's a link to it in Google Drive: https://drive.google.com/drive/folders/110hWYFenrT5Ymz5twMsEroS3zVCLi7jN?usp=sharing
The file seemed to contain a bunch of random characters, which I think may or may not be raw bytes according to my limited internet research? Here is what it said:
æ#z gÊ/ Èc| ZI> ♥ ☻ ýµ
☺▼Ïxœí]ol∟G§Ÿ=Û‰c'qâ$ý♥$]%¡
R←Çi„H♦¨ÆiÁRm§±)♣ ¢õÝÆY¸?fw/‰)↕◄¨B¨jÂ↨ª"!ñ…OHù‚„„ø H >ô‼â_)T¨)►J¨PZ’▬³swïnï2gßì¼Ý ›'­|Þ }3û{¿7³óöÍ®A◘1→ÛÖÆßW☼‼2¼P]ò↔¿hï˜ ZüÄä±#‼ôïý“Ç>♦%†▬éá ³–ï:↨Íù§Ûµ|§Röàø–9«d?f-ÙÅAú«¹û¤å7vÓ_°{ô”í:•BíÀ¦úo846U(8TµU¬↔®µñ/Á ÍOØ®↨ì‡ö_§zfÊùbµ×ªìÜY«►vnkì¬WÖT°³±»UióÐöÆ¡Fµµý# º¯Ñj>n—♥eùÇ∟ÏÿÂ^º·~lm-h+™ž_¢•†‚ 2NfOÛVa¾\\­ dù§w Q|sã/½ÄaÏ·\®Z2B¶↓)8® ¯ ýð‚SZ):gW☼›æ§\Ç·ÍýÕrÁ>ë”íÂ~ólÅ5í‹+®íÑöz¦ÎòM˵Íf™ÃPÑŽÒ™òŠ•·↨]Ë):ååË#­ ÷¬œñ|wºêù•ÒÉfÝÍFÞµrfé“ž}ÇñP“G♂¶—w §zà¾♠e aÓ*↨LJ7ת ◘pnýbÕöè♫ ÛU“°ñÌÕðÜJf▼¹¸òxã„Á ÐØX½ð–£ÿO}lúä#&Àe♠È\èÄë„iÖ ▬”Î◄òÜÜ☼J/ÏÞؕЃ♀…\f0d«]ùs§'oÏxs•²=vñœíÙkk´u„¼▲∟ß]´<¶RpÎ:v RqÑ)Õ
’{¬b±raúNMF¨Ðx©¦%_s¸♣ßò«^¸1F
’Q2← }n~éó =(·ŠÁv4Øèo;Ø~§lÔþW‚í3
Ÿ♫♫æ6(7▲•Õ’
ÎÙ▲l♂ÁÁ4΃KþNpùðÿ¡”t¼‼œ/ªã]†♫#´ÕÝÄuÊþ”7U].Ùeß.Ôý#è°àþ_L—É«c◘Ád„¡ƒ♥î°<↨ríúéC—zñ–ñF³DͲ† é ☻¤↑ž$è♣††<iÈATð☻Œ♫î­ôÇ‚,y " ƒh/h]»¨Ž[Ú♂2♠9ˆö☻<“è± k ƒh/¨K.}“ô›↨H 9HØ♂♠Hwi§←¸♦Ñ7ZuôèÛ3‼;~²úʕ׌6홈¾õÖQD · Ey↓±‰Ä‼*ãU↕—y;&•Œà<T°†‘¨pŒ¨¬~1Æî;ת’ÕY#™¢V↨¼T•¬Î→%¶µºà¥ªdõ„oÐ3|©*Y 0t(juÁK♣é´z71Ú~ÑmS¨¢ÑSne©h—▬WWl(C“$¶Î”V*nPñ£n¥´{¦∟Ì‹è∟é”kç­b¾Z¬6skvͻβS¶Š'ùÒ*è¹ÛàÜéFäí ­ŸÖÊß™95ÝLI¡ç¼▬œs/œ³û¾S^ö▲­¸Sùªã¯▲ì¸ân¨ ♫TÛ↑h›¯5ÜûšÑ*C'l{ɺ →h¶Õy2Œ<™]$Œe(O¦7‼ \Z↨]8¨ º•▬☻§²\s¶Zô ñõé¼yÁñÏ™5àó¶ÇDøÕ}]►^/‼‰☻↨=▬rß ¿üÓ¥7VŸ☻rƒd ▬↕)‼i”ô▬→aõô´,ÏhÑ↓w€(—,³Ï”îo¨ÝãD…¶#Ûˆ—♫,↔[↑:b¼Oês¸#Òf▼♠¶↑&aåGHÈ>Eà☻I›}↑PH g–ú> à☻Q }↑↔B▼±O☻¸#ÒfŸ,CIFîû¶ ♂„?ÆÖJ9↑$"Óì▼▲▼Üóé•Þ↑¤½æ♀L³{sP‘yuŽaÝ$æÕ↑Ì$œmÏHN#TH1àÀÐÁZC!aÿª◘\ i³☼#☼ ♥NÁ\¦¤Ø§◘\ i³ •#Ÿ♠œÃ♀↔↕²O◄¸#4ûê’‘‘W◄¸#ÒfŸ,CIFا◘\ ü©üPAü¹+½>Œ ?åN¶Ú±å¯|Ýh•◄Í_ ƒýœaÑC♫ËzfÚ ‡♣¢9 ¼§‘!ÔŽ0‼Ó·▼ì‚ézY+¶ªèá´Ñ+OþáÖôæIp↔ ♀„ÓbÍZ GÆh↓è×1Æ♣^↔C◘:0²V♠►Ú ±ò‡¥ƒc¬íÕì°E1;F#¶c•"♠ý V¬SÁ¸¹▬ñÆ·◄ ý{LOaxuì#Ðñ2µü6¹► 6½R¦•I»WÅ­xuü>¦¼¶^↔»◄®♣cŒ>Äh‡„½‚6½t¦•I»Wø3☻¶²Pã♠‚Ž♥♀³Ú+hÓKgz ´{♣Y♠Œ1„vPC‚☺£ßé¥ë§L♦“Pãß’ÜFbL.3Ò+hÓKgz►‘÷¢ÑÇ©ÑŸª|õéñ↔7þµû↨F›öL<UÁMRƒ↓Òˆ…˲üˆŠ♀í►LYHâé↓Fv•♠Tq=µ’å±R„Ε
Æm↨l$%8è÷”dˆéofèˆévGCŽ☻9HÚ^€‘€ù^♦81tdÄ♂4äÒy☺F§‚☺ç#ú&IÊ♂4äÒyÁ←’ÜdJ’¤¼#C. ↨♀Ï↑Qv L’¥;"E • {AŽt↨£í↨Ýâ_ËÑ=)=¹Õ← ûàêY«7V V↓ÑÕ←►„í¯µ♣∟ë5X†Ù½♠ìT Ó»ïøX¶yhªXü ‼Õ ”º º©ËŠ ¯ŒÔ◄Œþlổo>ÿ·Ñg¯æ:¬” g♂±®Øˆò©▬Z&êˆ÷Ž$1aŒG#↑í ü“xe‡ÈkuÖ8áÁ¢X♫☺RŒ←"‚ ♥ãQ♫¯↔zÕ D±Î‡ Ð;§áIHë‘©%×D…ãg◘V◄AÇ▼ŘÃ3‼Óp5%möaäæÀI÷e€}ŠÀ♣’6ûdq挰O◄¸#4ûêò€↑œýÆ>A¸#Òf▼ƃ§Œ°4Ë$↕²O◄¸#ø£çõä]→£+5¢•Ø&_↓¼ýf~mŸÑ¦=‼☺¶øß0Ì;7íœ‼G
…¼È☻#b↨×û\"x◘•´Ÿ´b¬↑¸Ž▬Œv∟►3♂O?¯!G ∟D♣/ Eǽb&É’↨È¢C►r►§¼#–Ž© ¼#◄ÈAÒö‚}Ú$I{ †:/À€S◄“$å♣→rÔ↑↕ ▼E !½ôío\ûç³·Þ͵iW(†Ôk¶•H¬‰7Ö↕Ž5↓ r$B½♥œõÆ•ªÂJ™áð‚¸ÌÂ{iXfÁ€¶#♦HÄÌ↕–´?6± q)¼:r◘:î↕ƒ”gˆÕp5%möa¬▼$◘:î◄ƒ3)ö)☻↨HÚìÛ) œï◄ƒ3)ö)☻↨HÚìÃ↑J0àÌHߧ◘\ *°o↑AÇëÉ¥Öh¸š↕õ½x4,BçýÑÃ"/þæûŸýåóç›♠☺Q&,"2¯æ} #”♣o"^€1ÿæM▼êu♫Ïá♣Y‰ ↓◘:X&‹ÐaPI{Șý¤H²^R á ¥◘\ i³☼á%€3)ö)☻↨HÚìÃHËfÝ;òêØ#♠gRìS♦.►§Ø' 3g‰}↕À♣¢ÙW↨Ö·x4ûâ‚♂D$TAçâÑC§sϼÿ[c3 ï2Ú´ëPEMèߨ) ÐN↕¡^Y>«‹‘F Ù{ØEÌ‚Ñé#Šñ WÁ¯↔óôó→r¶ÈA´↨à™D0ƪ½ qÈA´↨Ô♣ãy›àK´úÍ♂$€∟D♣/ÀXj. I²ä♣Š#♫¢½ .↕♀Ïýæ♣↕#♫Òé♣ݤu¬§C¢ Q£Ç f♠☼~ôò“W,ƒ´×Üw1¤pü•6↕ ◄↑/‘ňÿ↑◘íéàw↕p‼„ËÄ0Y\ï♫ŽÐ™PI{qí›◘♀¾▼☺RÖw2xu°↕Âb→V5ä( ƒ¤í♣ÿ‘Ä$↑ SF¼#C. ↨ÜD0ÉÁ˜àÄ0«„^ !—Î♂0²]÷Ç♦'¯Žÿ&↨hÐ £#♫¢‚↨ü)¦ç¹Ú♂T‡∟„?Ü♠§ÄÿÙÃõ¾í▬ÿ‡☼ Žë
ÿ♠m ▼>|Êh•‼ýða¿~¤¯‡O▼®gš
}¸M↔T▼삪yaÂœ*.ÛKA♂òf­PÞö˜XÏNtÁ:·Î•◄)„Ñ£ìwø{c§þ¹↨è¾pä2♥QöX?ˆÈêãy‼(Ñdƒ´rp1¢¯q·}£ ;Xªl„¶F↑𨤠%?#ÄïCX)Û"6↕Å—ç▲Nc'çê
ŒÙÙ8‚Ž[↓ä¥ŠØ ¤ÍK♀Ÿß‚ £_ûKÙ°♥I›—↑÷8↑؆mœ§^ªˆ↔HÚ¼$◘¸Ä¥CB☻↨ˆÈ{´i³¢Ïíwñ›K?zßÓ☼↓↔5g`nŸì·Ø içÃ↔M¯3{‘„SƒðÑt„´, (BŽ♣Z↕ Ǹm
gær7¾W
U♣Çigž‡?BÀí→"V¾Í¸)í¹b–Â◄Ö•♀ô¨PäJÆX§‹\ Ó&½^ Kaø+◄ ´ÙB◄&óÜ&h–↕¢Yš♠KAÒîk…nCDlS³8û,Nª¯Õ,Õ,Õ}­¾cèg▬+ß×j–ÀR►Ý×F©Xm▬_gA#%‹u_«Y?KAÒîk…È$b{!÷éyº§YLåZHa&ûZÍRÍRܾ6Gº‹Ñö‹nñ/ á_☺ ̲™ðÖ¹ µlæ²Ñ*'ºlF/ðˆ°˜f=ƒ½Ú o¡š÷笒½.K·7
a»¶ÉÁ£‡?x¶Ž
/Xçk↓∟; LN∟9>qô!óÈñ‼G œ86Ù´âBÊa'↔>e-Û♂Ηì\hçh#¡Àck°#‹ÿJ←►¸G làÈnÀ0ïáàœ«Á±_•œy)×:}lªì]◘ÚxÚ>o[E»►®o$¨ºR¬–Ê▲­ñÿ>_Ä|
I first tried opening the .ks-ipc file, and my computer asked what program to try opening it in, so I selected Word. It gave me all the random characters splayed out across a few pages, which was unhelpful. I then looked up what a .ks-ipc file was to see if there were any programs that could open it, but I found absolutely nothing about the existence of that file type. As far as Google is concerned, it doesn't exist. So I thought, okay, maybe it's just a weird ipc file, whatever an ipc file is, because Google does seem to know what an ipc file is. I try opening it in an ipc file converter that allows you to open and view them online. It tells me there's no readable text because it's a binary file and spits out the same random characters Word did. Did some googling and came to the conclusion that the random characters might be raw bytes, so I tried putting them into a raw bytes to string (text?) converter, but I got a few errors and it wouldn't work. The first error was there's an uneven amount of hex characters, the second was that there was an invalid UTF-8, whatever that means. I have no idea what any of this means, and I'm hoping somebody here can help me figure out what's going on. Is there any way to figure out what this says, or did my instructor just screw up?

Related

Loading pre-trained CBOW/skip-gram embeddings from a file that has unknown encoding?

I'm trying to load pre-trained word embeddings for the Arabic language (Mazajak embeddings: http://mazajak.inf.ed.ac.uk:8000/). The embeddings file does not have a particular extension and I'm struggling to get it to load. What's the usual process to load these embeddings?
I've tried doing with open("get_sg250", encoding = encoding) as file: file.readlines() for different encodings but it seems like none of them are the answer (utf-8 does not work at all), if I try windows-1256 I get gibberish:
e.g.
['8917028 300\n',
'</s> Hل®:0\x16ء:؟X§؛R8ڈ؛\xa0سî9K\u200fƒ::m¤9¼»“8¤p\u200c؛tعA:UU¾؛“_ع9‚Nƒ¹®G§¹قفگ؛ww$؛\u200eba:\x14.„:R¸پ:0–\x0b:–ü\x06:×#¦؛Yٍ²؛m ظ:{\x14¦:µ\x01‡:ه\x17S¹Yr¯:j\x03-¹ff€9×£P¸\n',
'W‚؛UUه9¼»é¹""§؛\u200c¶د:UU؟:\u200eb؟¹{\x14\u200d¸,ù19ïî\u200d؛ئ\x12¯؛\x00\x00ا:\u200c6°7A§a؛ذé„؛ذi†؛®G\x14:حجŒ8\x03\u200cè9ه\x17¸؛ق]¦؛ڈآ5¸قفا9حج^:\x00€ٹ؛q=²:\x00\x00¢9\x14®أ9×£T¹لz‚:\x1bèG؛®G7؛ڑ™<:m\xa0ƒ¹""´9\x14®\x1d:"¢²؛®G-؛ڑ™~:±ن¸:\x18ث«:¸\x1e…؛`,8؛Hل\u200d¹±ن.:\x1f…¥؛لْ‚:ڑ™s:R¸\x0b؛ئ’\x07؛0–C؛ڈآ¸:ذéھ:ة/خ¹A\'¸:ڑ™ز:m\xa0\x1e:è´ظ::ي‡؛\n',
'×\x05؛Œ%8؛ش\x06~؛أُu:\x00\x00\n',
":‰ˆ\x149\x14®?؛ِ(\x05:«ھ…:)\\‡833G:Haط؛\x1f…¼:¼»'9\x00\x00 ؛=\n",
'6؛R¸‚¹¼;€؛\x1bè¾؛\x1bèw؛قف؛:A§\x1a؛""j؛K~J:Hل\x14؛ىرد:\u200c6\x0c؛–|ب؛‚Nm:cةد·:mک؛‰ˆھ9\x00\x00ü9DD(¹ذi\x1f:ذé¬؛,ù™9¼»\x1e:wwƒ؛\x03\u200cF87ذ©·×£Q؛\x1f…w؛ئ\x12ح؛\x00\x00\x007ٍ‹U8\x0etZ6“ك«؛cةط؛Haد؛–ü¼؛33?¹Œ%َ9أُخ9=\n',
'‹؛ق]ع:ڈآ/؛0–ق¹¤pُ¹Dؤخ:¤p¤؛\x1bèت9\u200ebé¹ùE‹:–üb7=ٹ؛:؟Xv؛×£c؛ِ(·؛è4\xa0؛cة‹؛0\x16ˆ؛ئ’U:""#؛ة/j:R8،:أُى9ذé€:ىQX:\x1f…L:""›؛K\u200f•؛ڈآں؛‰ˆ8¸ww´:""o؛è´…؛\n',
'W·؛¤pگ:{”¶؛\x0etJ¹\u200eb>:ùإة؛`¬أ؛ِ(ü9K\u200f™:‚N؛:لz;:ِ(ٹ:Œ¥ˆ؛§\n',
'ں؛ِ¨\xad:ڑ™q؛\u200c6\x19:×£H9¤p\x1c:\x03\u200cخ¹–üٹ8UU\x13؛Hلؤ¹è´ء؛ïnژ؛®Gک:è´¯9\x0etN؛O\x1b\x0b؛\x00\x00Z:\n',
'Wڑ؛""J؛؟طخ:\x03\u200c¹:لْ¬؛\u200c6ک9ڑ™D؛\x1bèT8ق]ƒ:¼»س:0–-:~±³:,y‰:è´،¸jƒأ:m\xa0]:A\'د:j\x03\x15؛Haد:""½:wwù¹ه\x17ء؛×#س:&؟œ9×£5؛Hلz¹\\ڈ€¹)\\¨؛O\x1bْ¹ه\x17\x1b¹ڈB×؛\x03\u200c™؛ىQز¹لz¤¹ذi\x1c:\\ڈژ9ùإV¹R¸€:ùإü9ww?9‰\x08\u200d:~±ؤ¹‚Nù¹‰ˆ\x10¹UUn؛\x11\x11ƒ؛ٍ‹چ8‰ˆ½:\x1bèî¹O\x1bè¶`¬´؛=\n',
'¢:\n',
I've also tried using pickle but that also doesn't work.
Any suggestions on what I could try out?

(C) - How would one compare 2 txt files REQUESTS.txt and AVAILABLE.txt, separating each str read into a (STR6, STR3, STR3, INT) formatted Structure?

I have been working on this program for over a week with no breakthrough. The questions states as follows:
A ​disc​ ​file​ ​‘REQUESTS.TXT’​ ​contains​ ​airline​ ​flight​ ​data formatted​
​(STR6,​ ​STR3,​ ​STR3,​ ​INT)​.
Example:​
AA1011​SFx​LAx​​34​ ​(American Airlines​ ​1010,​ ​SF​ ​to​ ​LA,​ ​34​ ​seats)
W0924​DNV​DFW​​101​ ​(Western​ ​0924,​ ​DNV​ ​to​ ​DFW,​ ​101​ ​seats)
Another​ ​file​ ​‘AVAILABL.TXT’​ ​contains​ ​an​ ​unspecified​ number​ ​of​ ​reservation​ request​ ​records formatted​ ​identically​ ​as​ ​described​ ​above​ ​except​ ​the​ Seats​ ​Available​ ​field​ ​is​ ​a​ ​Seats​ ​Requested field.
Guidelines:
Read reservation flights and process requests. If the request can be fullfilled (i.e.. it is in AVAILABL and REQUESTS) then print "Reservation Processed", otherwise print "Reservation Denied".
Print out flight data file before and after reservations are processed, ordered by flight ID in a four(4) column format.
Print an overall outcome report for all processed.(Present totals for the number of requests satisfied and denied)
I have tried a few different approaches.. I tried to split up the first STR6 by isalpha/isdigit and combine them to make the FlightID (AA + 1011). Proceeded to try to then split up the remaining characters between STR3 and STR3 via isalpha + for loop. And lastly, I tried to take the last 3+ digits for the # of seats during each for loop iteration and multiply the first digit by 100(for a 3-digit value) or 10(for a 2-digit value), adding it to a running total for availSeats(INT). This, at least I thought so, would produce a
AA+1011 = AA1011(STR6) // W+0924 = W0924(STR6)
SFx(STR3) // DNV(STR3)
LAx(STR3) // DFW(STR3)
(3*10)+(4*1) = 34(INT) // (1*100)+(0*10)+(1*1) = 101(INT)
All of this stored within a Struct Array.
i.e...
FlightData Flight; ............................................FlightData Flight;
Flight[0].flightID = AA1011; .........................Flight[1].flightID = W0924;
Flight[0].fromCity = SFx; ...............................Flight[1].fromCity = DNV;
Flight[0].toCity = LAx; ..................................Flight[1].toCity = DFW;
Flight[0].seatsAvail = 34; .............................Flight[1].seatsAvail = 101;
I am really at a loss right now and have no other way to progress other than searching up different techniques/methods to use to make this work. I am a beginner clearly and will continue to practice and progress in C, but if anyone could provide me with a push in the right direction on how one would execute this via .txt into a Struct would be amazing. Also, if anyone has another method they used to solve this problem I would love to analyze it. Thanks!
(This is my first post, I spent a lot of time formatting it to be clear on Stackoverflow, so If i messed up in areas some constructive critisism would be useful! This applies to my posting and my coding practices. Thanks again!)
EDIT: The question I am asking here is how to successfully take a string such as AA1011SFxLAx34 and turn it into a Structure like the above diagram. It must also work for the second string W0924DNVDFW101 which has only 1 Char in its ID. (rather than two in AA1011). Im not sure what else I am supposed to edit after reading the guidelines.
I consider this a home work question, so I answer according to
How do I ask and answer homework questions?
Find a tutorial on C, work through it.
Then take a HelloWorld, modify it in small steps to approach your goal in steps from working program to working program. This way you should at least get to being able to read text from a file and print it.
Then learn to store parts of what you print into basic variables.
Then learn about structures.
And so on.
This way you will get quite close to the solution.
If it is not completely what you need show the code you have here at that point and ask a specific question about the first problem explaining what you suspect the problem to be. Show code which has exactly that one problem and makes it visible and has not other warnings (using at least e.g. gcc -Wall mycode).
Fix with the help of commments/answers you receive, repeat.

Altova Mapforce- Could not find start of message error

I am using Altomava Mapforce to map and load 837 x12 formatted text files directly to Sql Server 2014. I have correctly mapped everything except I get the following errors-
Missing field F142- Application Senders code
Could not find start of message with impl.convention reference '116731H333B2'. Message will be skipped.
Missing segment GE
I have included my header and footer information below from the original source text file. Does anyone know what is going on with the mapping, or if maybe there is something wrong with the data itself? Any help would be greatly appreciated.
Header-
ISA*11* *11* *PP* *ZZ*20121143 *273041*0109*^*00501*000000000*0*T*:~GS*HC**211231153*20141121*1115*01*Y*116731H333B2~ST*837*2000001*116731H333B2~BHT*0029*00*0003000005*20141121*1115*CH
Message Data etc.......
Footer-
~SE*769*2000001~GE*1*01~IEA*1*000000000~
Your data is wrong. Here is a cleaned up version of the ISA / GS. For readability, I put a CR/LF after the segment terminator (~). Please note the ISA and GS do not indicate sender, which is going to cause all kinds of problems for auditing. See my comment above for analysis on the data per your bullet points.
ISA*11* *11* *PP*SENDER *ZZ*20121143 *273041*0109*^*00501*000000000*0*T*:~
GS*HC*SENDER*211231153*20141121*1115*01*X*005010~
ST*837*2000001*116731H333B2~
BHT*0029*00*0003000005*20141121*1115*CH
An example of the enveloping:
ISA*00* *00* *ZZ*Test1Saver *ZZ*RECEIVER *151222*1932*U*00501*000111884*0*P*:~GS*HC*Test1Saver*RECEIVER*20151222*1932*1*X*005010~ST*850*0001~
...
~SE*8*0001~GE*1*1~IEA*1*000111884~
If, 123456789 have value then map 123456789 and if having null or blank or no value then send default 123.
enter image description here

boost log every hour

I'm using boost log and I want to make basic log principal file: new error log at the beginning of each hour (if error exists), and to name it like "file_%Y%m%d%H.log".
I have 2 problems with this boost library:
1. How to rotate file at the beginning of each hour?
This isn't possible with rotation_at_time_interval parameter because it creates new file regarding first written record in file, and the hour in file name doesn't match that rule. Is it possible to have multiple rotation_at_time_point for one file in sink or is there some other solution?
2. When file exceed some size I want it to start new file and in that case it should append some index to file name. With adding rotation_size parametar and %N to file name it will increment N all the time while application is running. I want that N to be reset at the beginning of each hour, just as my file name changes. Does anybody have any idea how to do that with this boost log library?
This is basic principal in creating log files in industry. I really don't understand how this can't be done with library which is dedicated for creating log files.
Library itself doesn't provide a way to rotate file at the begging of every hour, but i had same problem so i used a function wrapper, which return true on begging of every hour.
I find this way better for me, because i can controll efficency of code.
from boost.org:
bool is_it_time_to_rotate();
void init_logging(){
boost::shared_ptr< sinks::text_file_backend > backend =
boost::make_shared< sinks::text_file_backend >(
keywords::file_name = "file_%5N.log",
keywords::time_based_rotation = &is_it_time_to_rotate
);
}
For a second question i really dont undrestand it well.

How do I get a temporary File object (of correct content-type, without writing to disk) directly from a ZipEntry (RubyZip, Paperclip, Rails 3)?

I'm currently trying to attach image files to a model directly from a zip file (i.e. without first saving them on a disk). It seems like there should be a clearer way of converting a ZipEntry to a Tempfile or File that can be stored in memory to be passed to another method or object that knows what to do with it.
Here's my code:
def extract (file = nil)
Zip::ZipFile.open(file) { |zip_file|
zip_file.each { |image|
photo = self.photos.build
# photo.image = image # this doesn't work
# photo.image = File.open image # also doesn't work
# photo.image = File.new image.filename
photo.save
}
}
end
But the problem is that photo.image is an attachment (via paperclip) to the model, and assigning something as an attachment requires that something to be a File object. However, I cannot for the life of me figure out how to convert a ZipEntry to a File. The only way I've seen of opening or creating a File is to use a string to its path - meaning I have to extract the file to a location. Really, that just seems silly. Why can't I just extract the ZipEntry file to the output stream and convert it to a File there?
So the ultimate question: Can I extract a ZipEntry from a Zip file and turn it directly into a File object (or attach it directly as a Paperclip object)? Or am I stuck actually storing it on the hard drive before I can attach it, even though that version will be deleted in the end?
UPDATE
Thanks to blueberry fields, I think I'm a little closer to my solution. Here's the line of code that I added, and it gives me the Tempfile/File that I need:
photo.image = zip_file.get_output_stream image
However, my Photo object won't accept the file that's getting passed, since it's not an image/jpeg. In fact, checking the content_type of the file shows application/x-empty. I think this may be because getting the output stream seems to append a timestamp to the end of the file, so that it ends up looking like imagename.jpg20110203-20203-hukq0n. Edit: Also, the tempfile that it creates doesn't contain any data and is of size 0. So it's looking like this might not be the answer.
So, next question: does anyone know how to get this to give me an image/jpeg file?
UPDATE:
I've been playing around with this some more. It seems output stream is not the way to go, but rather an input stream (which is which has always kind of confused me). Using get_input_stream on the ZipEntry, I get the binary data in the file. I think now I just need to figure out how to get this into a Paperclip attachment (as a File object). I've tried pushing the ZipInputStream directly to the attachment, but of course, that doesn't work. I really find it hard to believe that no one has tried to cast an extracted ZipEntry as a File. Is there some reason that this would be considered bad programming practice? It seems to me like skipping the disk write for a temp file would be perfectly acceptable and supported in something like Zip archive management.
Anyway, the question still stands:
Is there a way of converting an Input Stream to a File object (or Tempfile)? Preferably without having to write to a disk.
Try this
Zip::ZipFile.open(params[:avatar].path) do |zipfile|
zipfile.each do |entry|
filename = entry.name
basename = File.basename(filename)
tempfile = Tempfile.new(basename)
tempfile.binmode
tempfile.write entry.get_input_stream.read
user = User.new
user.avatar = {
:tempfile => tempfile,
:filename => filename
}
user.save
end
end
Check out the get_input_stream and get_output_stream messages on ZipFile.

Resources