Change TextMate live webpreview to use Chrome's Webkit - webkit

Currently Textmate uses Safari's Webkit to render the hmlt outputs for both commands and the live webpreview window.
Unfortunately for one specific project I am working with specific javascript API supported only be Firefox's gecko or Chrome's Webkit, it seems Safari still not supporting it.
Perhaps there's a way to globally change Safari for Chromium or Webkit Nightly?

A support member of TextMate kindly answered my email asking for it by mentioning this url which definitely points to the right solution. I really didn't think it could be done so seamlessly and now I am very happy that it is possible.
Basically there are few steps to follow:
$ cd /Applications/TextMate.app/Contents/MacOS/
$ mv TextMate _TextMate
$ vim TextMate
new TextMate file contains (note that you might want to change the path for the new webkit framework to fit the one you like)
#!/bin/bash
env DYLD_FRAMEWORK_PATH=/Applications/WebKit.app/Contents/Frameworks/10.6/WEBKIT_UNSET_DYLD_FRAMEWORK_PATH=YES /Applications/TextMate.app/Contents/MacOS/_TextMate
after saving the newly created file:
$ chmod a+x TextMate
Close/Run TextMate :)
Or obvious if you just want to do this for each session you can simply use the bash command right away from terminal like this:
$ env DYLD_FRAMEWORK_PATH=/Applications/WebKit.app/Contents/Frameworks/10.6/ WEBKIT_UNSET_DYLD_FRAMEWORK_PATH=YES /Applications/TextMate.app/Contents/MacOS/TextMate
This is really cool...one thing I've noticed after that is that my themes are no longer being displayed, have no clue about it but I will try to check the cause.

try this - http://wiki.macromates.com/Main/Howtos#SafariPreview

Related

Phantomjs not render hebrew fonts

I am using PhantomJs 1.9.2 on Centos 6.3 to for automated ui tests. When a test fails,
screenshots are saved to the server.
My problem is that even though the screenshots are saved, they do not contain readable fonts.
So if the website reads like this:
חיים טכנולוגיים
the screenshot of the site will look like this:
םםםםםםםםםםםםם
So, instead of the actual letters, it renders and saves little boxes.
The system is centos 6.3. Freetype and Fontconfig are also installed.
How could I go about fixing this?
Thanks!
follow these steps:
in /usr/share/fonts/ I added a folder named arial with the arial.ttf for hebrew
I ran fc-cache -vf.
That's it! I did not edit or change fonts.conf or did anything else as suggested in the link.
You should use python code for taking screenshots of website. there are two module which will do whatever you want pyvirtualdisplay & selenium. Install them and write a class to create screenshot and call it with command line with your code.
Best of luck...
I recently had to fix the same problem myself. I ended up doing what's suggested in the this answer. Well, sort of. I skipped some of the steps:
in /usr/share/fonts/ I added a folder named arial with the arial.ttf for hebrew
I ran fc-cache -vf.
That's it! I did not edit or change fonts.conf or did anything else as suggested in the link.
Granted, I still had a little trouble with parts of the page (I'm guessing it was because they were using fonts other than arial), but I ended up not needing them. Hopefully that'll be good enough for you too!

Effortless export from github wiki (?)

I am collecting quite a lot of material in a GitHub wiki. I really like to use the wiki to cooperate with other people and IMHO the platform is really nice, I like it!
So, I would like to keep using the GH wiki to collect stuff, edit, save,etc but I also would like to export the content in order to create a pdf file that we can call "a manual".
I would like to generate an updated version of the manual automatically everytime I want just running a couple of scripts, I can not put too much effort on this.
I guess it is possible to export the content somehow and the use pandoc (http://johnmacfarlane.net/pandoc/) to create the pdf maybe adding an index and a style file.
Another interesting idea could be publish a website once a month dumping content directly from the wiki.
I guess other people already did something like this but I did not find anynthing.
Any idea?
But... the Github wiki of a GitHub repo is a git repo in itself (introduced in August 2010).
You can clone it, push to it or pull from it.
Each wiki is a Git repository, so you're able to push and pull them like anything else.
Each wiki respects the same permissions as the source repository.
Just add ".wiki" to any repository name in the URL, and you're ready to go.
Or, as noted by htafoya in the comments, replace the .git part of the URL (if present) by .wiki.
That makes the "export" part of your question really trivial.
From there, you will find tons of script for converting markdown pages into pdf:
a graddle task
a makefile
a python script
...
I'm adding to this answer, in case it helps any new readers :) here's what I did:
I installed GitHub Desktop: https://desktop.github.com/
Then, on the wiki page in my repository, I clicked "Clone in Desktop"
This saved the wiki locally as a .md file (after following the steps on screen)
I then used http://www.markdowntopdf.com/ to convert it to pdf
(Note: I renamed the files to remove characters that wouldn't work in a pdf file name before uploading to the website)
The end result was really nice.
I found many of the solutions difficult to reproduce/get the right version/understand/fix/etc... So instead, I'll present a patchwork docker solution to effortlessly convert on Windows(using git bash)/MacOS/Linux in 5 "easy" commands
git clone {project_url}.wiki .
# Convert *.md to *.md.html using the actual github pipeline
docker run --rm -e DOCKER_USER_ID=`id -u` -e DOCKER_GROUP_ID=`id -u` \
v "`pwd`:/src" -v "`pwd`:/out" andyneff/github-markdown-preview
# Fix hyperlinks, since wkhtmltopdf is stricter than github servers
docker run --rm -v `pwd`:/src -w /src perl \
perl -p -i -e 's|(.*?)|\1\L\2\E.md.html\L\3\E\4|g'\
*.html
# Lowercase all filename so that hyperlink match
docker run --rm -v `pwd`:/src -w /src python \
python -c 'import sys;import os; [os.rename(f, f.lower()) for f in sys.argv[1:]]' \
*.md.html
#Convert html to pdf using QT webkit
docker run -it --rm -e DOCKER_USER_ID=`id -u` -e DOCKER_GROUP_ID=`id -u`\
-v `pwd`:/work -w /work andyneff/wkhtmltopdf \
wkhtmltopdf --encoding utf-8 --minimum-font-size 14 \
--footer-left "[date]" --footer-right "[page] / [topage]" \
--footer-font-size 10 \
toc \
*.html document.pdf
The perl is the main part that may fail without a better solution. Pandoc has a really good filter solution, but isn't using the github pipeline.
Bugs:
Extra wide code blocks will be rendered with a scroll bar, and essentially cut off in the pdf. It would be best to make the code block not overflow, but you can add --user-style-sheet user.css to the wkhtmltopdf command (before toc/cover), and add to your user.css
.markdown-body .highlight pre,
.markdown-body pre{
overflow:visible !important;
}
Some link in the final pdf are off by +1 page, some are not. Not sure what the pattern is. But anchors with ids (#) do not appear to have this problem
Another option once you clone the wiki, especially if you are already using Atom is to use this Markdown to PDF package.
Worked great for me.
I found really annoying having to convert each markdown document separately (links between markdown documents are lost), so I ended up writting a simple C# program for my own use that does this in a single step: a) Download the last version of the wiki from Github, b) Convert it all the markdown documents merged as one pdf
You can download the binaries (Windows or any platform supporting Mono) from:
https://github.com/borjafdezgauna/CoderDocTools/releases/latest
If, for example, you want to convert to PDF the SimionZoo repository by user simionsoft, you can:
MarkdownToPDF.exe user=simionsoft project=SimionZoo output-file=SimionZoo.pdf
I've accomplished precisely this when creating the portable documentation for Barcode Writer in Pure PostScript:
GitHub Wiki + Makefile + pandoc → PDF
The process is described in this blog post.
This question has already been answered but wanted to add my quick experience here.
I didn't find it necessary to install the Desktop version of Github. You can clone by simply running the following from your commandline:
git clone git#github.com:<username>/<repository>.wiki.git
(Of course, replace username and repository as needed).
The cloned wiki outputted 72 markdown files. As has been previously said, there are numerous ways of converting these files do PDF, you can pick your own tool. However I will say that the easiest solution I encountered was to install Pandoc. I have macOS + homebrew, so a quick brew install pandoc was all I needed.
Some info on using pandoc here: https://stackoverflow.com/a/14908316/3638172
You can also try html_links_to_pdf!
It's a Python 3 script made just to convert a GitHub Wiki to pdf form, using the same styling that GitHub uses, but slightly cleaner.

Why can't I access to Rails via multiples shells bash and zsh on OSX Lion

I installed Ruby on Rails 3 using bash on OSX Lion.
When I wanted to use zsh and do a "rails -v" command I had "Rails is not currently installed on this system".
I just do not understand why. To me it's like "you can access all the files you want with bash not with zsh".
If I want to switch to zsh, will I have to install one more time Rails? delete the old one?
Is it secure and clever to use two shells when developing Rails applications?
What are your best practices?
Thanks in advance.
PS: I am new to programming and my installation is working fine. I even created one app.
EDIT: If you encounter the same problem I would encourage you to read the second answer first to get the rationale then the first one. Thanks to both of them.
While you are running bash, type at the command line echo $PATH.
Now start up your zsh command line, and type echo $PATH.
I bet the Rails path is not included in your zsh, right?
Look in your $HOME dir for .bash* files. See which one has the Rails PATH added.
Find your zsh .* env files and copy/paste the line you found above into the approriate file.
When I say .bash* and .* files, I mean hidden files in your home dir that you'll only find by doing ls -la. If you find a .profile file, that would be a good place to insert this.
I hope this helps.
P.S. as you appear to be a new user, if you get an answer that helps you please remember to mark it as accepted, and/or give it a + (or -) as a useful answer.
I just do not understand why. To me it's like "you can access all the
files you want with bash not with zsh".
As shellter said, you must have directories added to your path in order to run commands from the command line. For more information on PATHs take a look at the Intro to Linux guide. I know you are not using Linux but that section (and lots of others) is very much applicable.
If I want to switch to zsh, will I have to install one more time
Rails? delete the old one?
No, see note on paths above and take a look at the guide.
Is it secure and clever to use two shells when developing Rails
applications? What are your best practices?
It's not really something special to use two shells at once. It depends what you do in each. I often have 6 and 7 shells open, not all for the same thing. That is really up to you and how you work. The number of shells you use is more of a workflow thing than a "best-practices" issue.
I normally have 3 shells open when I do RoR work. One running autotest in the background, one running rails -server, and one where I actually edit files and run emacs. But again, this is not best practice as it is workflow. Do whatever makes you effective.
The only trouble you could get into occasionally running two shells is say, for example, you open a file in one and delete it in another. However, when you do this it is typically very obvious.
PS: I am new to programming and my installation is working fine. I
even created one app.
For Rails, I found this tutorial very helpful.
Also, you said you were new to programming. I don't know if this is the case, but I would suggest starting with basic Ruby, before jumping into Perl. Although the tutorial I linked above covers Rails-flavored Ruby.

.vimrc for IntelliJ Idea's vim plugin

I am using the vim plugin for IntelliJ Idea.
Where should I place the .vimrc for that plugin.
Using Windows XP
The latest version of the plugin will read settings from a file named .ideavimrc in the home directory.
On *nix, the home directory can be accessed at ~.
On Windows, you can use the %HOMEPATH% environment variable. (Normally, "C:\Users\<User Name>" or "C:\Documents and Settings\<User Name>", depending on your Windows version.)
If you rename your .vimrc to _ideavimrc in your ~ directory (/Users/ in windows)
Underscore is used instead of the . in windows for vim apparently
IntelliJ will honour it
Was tearing my hair out for a while getting this to work.
On my mac i simply ran ln -s "$HOME/.vimrc" "$HOME/.ideavimrc" to create a symlink so IntelliJ would use the same .vimrc as my standard vim.
My .vimrc is very simple. However, if there is config that is incompatible between IntelliJ and vim then you might have issues with this approach.
echo %homepath%
gives me my "home directory" on Windows XP,
where I need to put my .vimrc.
Unfortunately, the vim plugin for JetBrains doesn't effectively support the full functionality of a .vimrc. The file that the plugin uses is called .ideavimrc. This is what you should use and it should be placed in your home directory (see this other answer for details, particularly for Windows).
I have a very comprehensive .vimrc that I use. Unfortunately, I had to pare that down quite a bit to work as .ideavimrc. You can look at the gists to see the differences. For what it's worth, it's still provides nice functionality, including buffer switching across tabs and splits.
.ideavimrc
.vimrc
So why not just use the same file (i.e., .vimrc) for both? Well, for one thing, you need some settings in .ideavimrc that give precedence to the vim plugin for certain keyboard shortcuts that conflict with the IDE. See the top of my .ideavimrc for my settings (for example, sethandler <C-B> a:vim). The other thing is that it seemed that when my more complicated .vimrc couldn't be processed, other settings (such as just set noerrorbells) also wouldn't take effect.

How to debug a Screensaver in OS X

I was wondering if there was any decent way, other than NSLog-ing just about everything - to properly debug a Screensaver app bundle in OS X?
The "Screensaver" is a project type in Xcode, but there's obviously no Build and Go debugging. Further, I've found that in fact my bundle is getting loaded in to the
/System/Library/Frameworks/ScreenSaver.framework/Versions/A/Resources/ScreenSaverEngine.app
application as some sort of plugin.
So is there a decent way to debug your code? Looking at crash reports and NSLog-ing to the console helps, but it's far from perfect.
There is an old MacTech article that describes the Screen Saver development cycle. There is also a Part 2 to the article. Look in the "Debugging Tips" section.
I find this method a pain so I wrote an application, the basic application was one window and a controller that initialized a ScreenSaverView with my new screensaver bundle. Once that was working all I had to do to test a change was hit Command-R in Xcode.
Because of OS X 10.11 El Capitan's System Integrity Protection feature, the debugger can't attach to anything running from /System/. Also, the other info here applies to old versions of Xcode.
Here's how I got it working on El Capitan with Xcode 7.2:
Copy /System/Library/Frameworks/ScreenSaver.framework/Versions/A/Resources/ScreenSaverEngine.app/ to /tmp/. (Since the .xcscheme references the fully-qualified path, copying it to someplace common is best for collaboration, instead of to somewhere in a particular user's home directory.)
Edit the project's .xcscheme:
Set the Executable for its Run action to the copied app, and add the arguments: -debug -background -module "<product-name>" (where <product-name> is the bundle name without the .saver extension).
Add a Pre-action script (source below), with its shell set to /bin/bash and its build settings to come from the scheme. It creates a symbolic link to the built .saver bundle in ~/Library/Screen Savers/
Source:
SCREEN_SAVER_PATH="${HOME}/Library/Screen Savers/${FULL_PRODUCT_NAME}"
if [[ -d "${SCREEN_SAVER_PATH}" || -f "${SCREEN_SAVER_PATH}" || -L "${SCREEN_SAVER_PATH}" ]]; then
rm -Rf "${SCREEN_SAVER_PATH}"
fi
ln -s "${BUILT_PRODUCTS_DIR}/${FULL_PRODUCT_NAME}" "${SCREEN_SAVER_PATH}"
Now, when you hit Xcode's Run button, the screen saver will run in wallpaper mode on your Desktop, and you can use the debugger.
You can debug plugins by executing the application that will load the plugin.
So to debug a screensaver, open your plugin project, choose New Custom Executable from the Project menu and set the application to be the screensaver engine.
For debugging a screensaver, you might also want to use a second Mac and use remote debugging so your user interface actions don't interfere with the screensaver.
There's a few Mac OS X apps that will run screen savers: SaverLab, Screenalicious, etc.
Just find one of them on the web and download it and then set it as the target executable (as Peter N Lewis said).
To avoid copying the build product to '~/Library/Screen Savers/' after each build you can add a custom build script (note: I'm using '/bin/tcsh -x' for the shell):
#remove the old screen saver or link
rm -Rf "${SCRIPT_OUTPUT_FILE_0}"
#if this is a debug build…
if ("${CONFIGURATION}" == "Debug" ) then
# create a symbolic link from our screen saver to this users screen saver directory
ln -sfv "${SCRIPT_INPUT_FILE_0}" "${SCRIPT_OUTPUT_FILE_0}"
#if this is a release build…
else if ("${CONFIGURATION}" == "Release" ) then
# copy our screen saver to this users CMM directory
cp -Rfv "${SCRIPT_INPUT_FILE_0}" "${SCRIPT_OUTPUT_FILE_0}"
endif
Then set its input file to "${BUILT_PRODUCTS_DIR}/${FULL_PRODUCT_NAME}" and its output file to "${HOME}/Library/Screen Savers/${FULL_PRODUCT_NAME}".
Now when you build / run your project it will auto-magicly link to your debug build or copy your release build.
You could also make the screensaver engine ('/System/Library/Frameworks/ScreenSaver.framework/Resources/ScreenSaverEngine.app') the target executable and pass it the -background flag (so it runs behind everything instead of in front of everything).
As Peter says, you can debug the plugin by executing an application that will load the plugin.
However, rather than using the screensaver engine you could also use system preferences. When the preferences appear navigate to your screensaver under "Desktop & Screen Saver" to load your plugin.
It's not perfect as your view won't be full size, but it can be easier than setting up remote debugging.
not necessarily the best way, but you could ssh in from another machine and launch ScreenSaverEngine from gdb (untested)
edit:
also, you could try adding a new application target and add your ScreenSaverView to a window in IB, you may have to manually configure stuff like settings, but it could help some and should probably work OK as ScreenSaverView is a subclass of NSView
If you make a copy of the ScreenSaverEngine app, and sign it with your Developer ID, it will fix the situation where System Integrity Protection prevents attaching the debugger. Just make sure to set the executable to your own-signed copy.
I would like to note that #Karl's solution worked the best for me.
However, if you are like me and you reboot your computer every night you may want to think about putting:
cp -Rn /System/Library/CoreServices/ScreenSaverEngine.app /tmp
at the beginning of the pre-Build shell script mentioned in his answer. This will automatically do the copying step for you.
(though I believe this really belongs in a comment, my xp is not yet high enough)