<b>Linux Journal:</b> "After a recent O/S version upgrade (to openSUSE 11.2) I noticed that bash started being a bit more intelligent when I did something stupid: it started giving me a useful error message..."
I occasionally write code like this when I want to replace small parts of an existing implementation:
public interface IFoo
{
void Bar();
}
public class Foo : IFoo
{
public void Bar()
{
}
}
public class ProxyFoo : IFoo
{
private IFoo _Implementation;
public ProxyFoo(IFoo implementation)
{
this._Implementation = implementation;
}
#region IFoo Members
public void Bar()
{
this._Implementation.Bar();
}
#endregion
}
This is a much smaller example than the real life cases in which I've used this pattern, but if implementing an existing interface or abstract class would require lots of code, most of which is already written, but I need to change a small part of the behaviour, then I will use this pattern.
Is this a pattern or an anti pattern? If so, does it have a name and are there any well known pros and cons to this approach?
Is there a better way to achieve the same result? Rewriting the interfaces and/or the concrete implementation is not normally an option as it will be provided by a third party library.
Is it possible to create a terminal application which uses cocos2d? I've tried to make one using cocos2d 2.x, but it requires a MacGLView to be initialized.
I need it so that I could program a terminal application that generates a screenshot given a TMX file and an optional preferred width or height parameter (for resizing). Then I can automate the generation of map previews for my game, instead of manually taking screenshots. It's not practical to load the actual TMX and resize it inside the game (what I'm currently doing), because each TMX file has 7 layers, my tile sheet is huge, and I have lots of levels.
tl;dr: How does the ubuntu user on the AWS images for Ubuntu Server 12.04 have passwordless sudo for all commands when there is no configuration for it in `/etc/sudoers'?
I'm using Ubuntu server 12.04 on Amazon. I want to add a new user that has the same behaviour as the default ubuntu user. Specifically I want passwordless sudo for this new user.
So I've added a new user and went to edit /etc/sudoers (using visudo of course). From reading that file it seemed like the default ubuntu user was getting it's passwordless sudo from being a member of the admin group. So I added my new user to that. Which didn't work. Then I tried adding the NOPASSWD directive to sudoers. Which also didn't work.
Anyway, now I'm just curious. How does the ubuntu user get passwordless privileges if they aren't defined in /etc/sudoers. What is the mechanism that allows this?
I have XAMPP installed and my PHP is:
/opt/lampp/bin/php-5.3.8
Every time I need to execute a PHP file I need to do this:
/opt/lampp/bin/php-5.3.8 testando.php
Is there another way to execute it besides using symbolic link?
I did this on /etc/init.d/:
sudo ln -s /opt/lampp/bin/php-5.3.8 php
Why when I need to run PHP I have to do this ./php instead of just php?
And is there a way to do this without the ./? Like it was installed via apt-get?
I am getting an error while executing a remote PowerShell script. From my local machine I am running a PowerShell script that uses Invoke-Command to cd into a directory on a remote Amazon Windows Server instance, and a subsequent Invoke-Command to execute script that lives on that server instance. The script on the server is trying to git clone a repository from GitHub. I can successfully do things in the server script like "ls" or even "git --version". However git clone, git pull, etc. result in the following error:
Cloning into 'MyRepo'... + CategoryInfo : NotSpecified: (Cloning into 'MyRepo'...:String) [], RemoteException + FullyQualifiedErrorId : NativeCommandError
This is my first time using PowerShell or a Windows Server. Can anyone provide some direction on this problem.
The client script:
$s = new-pssession -computername $server -credential $user
invoke-command -session $s -scriptblock { cd C:\Repos; ls }
invoke-command -session $s -scriptblock { param ($repo, $branch) & '.\clone.ps1' -repository $repo -branch $branch} -ArgumentList $repository, $branch
exit-pssession
The server script:
param([string]$repository = "repository", [string]$branch = "branch")
git --version
start-process -FilePath git -ArgumentList ("clone", "-b $branch https://github.com/MyGithub/$repository.git") -Wait
I've changed the server script to use start process and it is no longer throwing the exception. It creates the new repository directory and the .git directory but doesn't write any of the files from the github repository. This smells like a permissions issue. Once again invoking the script manually (remote desktop into the amazon box and execute it from powershell) works like a charm.
<b>The Geek Stuff:</b> "In this article, let us review various tar examples including how to create tar archives (with gzip and bzip compression), extract a single file or directory, view tar archive contents, validate the integrity of tar archives, finding out the difference between tar archive and file system, estimate the size of the tar archives before creating it"
I'm running 10.04LTS inside VMWare Fusion on a Mac.
The [command] key (aka [windows] on many keyboards) is almost always behaving as if it was [ctrl], even though I done anything explicit to request that behavior.
In fact, in SystemPreferencesKeyboardLayoutsOptionsAlt/Win key behavior, 'default' is chosen (rather than the 'Control is mapped to Win keys' option). However, choosing other options there do not seem to change the handling of [command], at least not as tested in the SystemPreferenceKeyboard Shortcuts app. (No matter what I've tried, [command]-x is always detected as [Ctrl]-x in that app.)
I've tried:
various options under SystemPreferencesKeyboardLayoutsOptionsAlt/Win key behavior
toggling the VMWare Fusion Preferences KKeyboard & Mouse Key Mappings setup which claims to map '[command]' to '[windows]', and restarting the VM in each position
the xmodmap lines suggested at https://help.ubuntu.com/community/MappingWindowsKey
And yet, it's clear that all Ubuntu apps aren't merging [ctrl] and [command], because in 'Terminal', [shift]-[ctrl]-c will Copy, but [shift]-[command]-c will not.
If the [command]/[windows] key was recognized as anything else ('Super', 'Meta', 'Hyper'? I don't care as long as it's not 'Control'), then I could achieve my real goal (which happens to be enabling CMD-based cut/copy/paste in PyCharm, while leaving CTRL-X/etc available for emacs-like bindings). I think any solution which manages to make [command]-x appear as something other than [ctrl]-x in PreferencesKeyboard Shortcuts will probably do the trick.
In bash, when I go back in history, edit some command and run it, this edited command is appended to history and the original one is left intact. But every once in a while I somehow manage to affect the original command, i.e. my edit replaces the original command back in history. I can't put my finger on how this happens. Can someone explain? My goal is to avoid this, so any edit to a previous command always gets appended to history and never replaces the original.
I had an idea of using my Windows VM (on a Ubuntu host) to open itms:// links (for iTunes) from the host. So, I'm using vboxmanage guestcontrol to make this happen.
I have a script (win_vm_launcher.sh) that takes a link as the argument, and passes it to the host like this:
vboxmanage guestcontrol "$VM" exec --image 'C:\Windows\System32\cmd.exe' --username "$USER" --password "$PASSWORD" -- /c start "$@"
This works if I copy a link from my browser, and change http to itms. E.g., for https://itunes.apple.com/us/album/new-york-city/id3202598, I can do win_vm_launcher.sh itmss://itunes.apple.com/us/album/new-york-city/id3202598 and it works fine. The album opens up in iTunes on my VM.
However, when I click a "View in iTunes" link from the iTunes site, it adds an extra parameter to the URI (specifically, the referrer), so it looks something like itmss://itunes.apple.com/us/album/new-york-city/id3202598?ign-msr=https%3A%2F%2Fitunes.apple.com%2Fus%2Falbum%2Fit-came-upon-midnight-clear%2Fid578946739
Unfortunately, if I try to run win_vm_launcher.sh itmss://itunes.apple.com/us/album/new-york-city/id3202598?ign-msr=https%3A%2F%2Fitunes.apple.com%2Fus%2Falbum%2Fit-came-upon-midnight-clear%2Fid578946739 it insteads opens up a regular Command Prompt window with the title "itmss://itunes.apple.com/us/album/new-york-city/id3202598?ign-msr=https%3A%2F%2Fitunes.apple.com%2Fus%2Falbum%2Fit-came-upon-midnight-clear%2Fid578946739". I don't even know how to set the command prompt window title, so I'm not sure how that's happening.
If I run the command in the guest, it works fine, opening the album in iTunes:
cmd /c start itmss://itunes.apple.com/us/album/new-york-city/id3202598?ign-msr=https%3A%2F%2Fitunes.apple.com%2Fus%2Falbum%2Fit-came-upon-midnight-clear%2Fid578946739
I found a VirtualBox bug that seems somewhat related, but not exactly.
It probably doesn't matter, but my host is Ubuntu 12.04, and my guest is Windows 7.
So, any idea if vboxmanage is incorrectly passing the arguments, and if so, is there a way around it?
If I can't figure out the right way to do it, I'll end up having to process each argument, and stripping out any parameters on any URIs.
P.S.
I tried creating a batch script (out.bat) like this:
echo %1 > %TEMP%/testing.txt
and then running it from the host like this: vboxmanage guestcontrol "$VM" exec --image 'C:\Windows\System32\cmd.exe' --username "$USER" --password "$PASSWORD" -- /c "C:\path\to\out.bat" "itmss://itunes.apple.com/us/album/new-york-city/id3202598?ign-msr=https%3A%2F%2Fitunes.apple.com%2Fus%2Falbum%2Fit-came-upon-midnight-clear%2Fid578946739"
It ran as expected, and when I open %TEMP%/testing.txt, it contained:
"itmss://itunes.apple.com/us/album/new-york-city/id3202598?ign-msr=https%3A%2F%2Fitunes.apple.com%2Fus%2Falbum%2Fit-came-upon-midnight-clear%2Fid578946739"
including the quotes. So, it sort of passed the parameter correctly (not sure why it still had quotes), so maybe the problem is with cmd.exe, or even the start command. I'm stymied.
How can I specify multiple startup tasks in Conemu? I want to have each task in a separate tab opened on startup.
Something like:
ConEmu64.exe /cmdlist {Powershell}|{FAR}|{VSConsole}
Unfortunately, this command does not support "console scripts" ("Console script are not supported here").
I know, I can create another task, combining the commands of my desired tasks (full commands, because task command does not support console scripts). Is there any other way ?
I have some command-line commands to execute on a Windows machine. The programs I need to run are only available on Windows.
Is there a way to easily to do something like I would do with SSH? Example of what I mean:
ssh [email protected] "remote command to execute"
...or do I have to Remote Desktop just to do this? (I'd like to run the commands programmatically from another computer rather than running them by hand.)
Please share your favorite mc tips here.
My favorites:
I just learned that Alt+. enables easily to toggle display of hidden files (on mc 4.7).
Ctrl+\ - favorite dirs
Alt+s - quick search
BTW:
how to use command line completion without switching to Ctrl+o mode? (TAB does not work, since it changes panels)
how to insert full path of the current panel into the command line?
I'm trying to show the number of lines, words and characters of all configuration files in /etc/*conf (with command wc).
How can I modify the command (or commandline) to not view the error messages?
From a Windows XP command line, how do I get the time I logged into and/or out of the current machine? I'm looking for something like the UNIX last command which lists active and previous login sessions.
Thanks,
John
I would like to extract a "book cover image" from a series of CHM files, which command line tool can do that, please?
I have looked at the source of the QuickLook plug-in "quickchm1.1_source" and at the calibre command line conversion options (ebook-convert) but couldn't find anything akin to simple:
name_of_tool file_to_convert output_image
as in:
mytool routermanual.chm routermanualcoverimage.png
I know that the copy command has an option to automatically replace a file if it already exists, but I want to know if it is a way to copy the files only if they not already exist (/Y). I do not know the actual file names in the batch code, as I copy from the source using wildcards in the copy command:
copy *.zip c:\destination
The reason I want this instead of automatic overwrite is that the files are large, and to skip existing would save a lot of execution time.
I am attempting to use the zip -r command to zip a folder which includes two files. I need to pass the absolute path of the folder with two files (/path/to/my/files/), which is causing all of the folders to be zipped with it, where as I only need the last folder (files/) and its contents to be zipped, so that when the file is unzipped, there is only one folder and the two files within it. How can I modify the command to be able to pass the absolute paths in the arguments while keeping only the last folder?
I work a LOT in the windows command line. Unlike other windows, it doesn't maximize - it just goes a big as it can depending on the buffer size. Is there any way I can get the CMD to act like the PuTTY console, flowing with the resize?
NOTE: The answer doesn't have to be a tweak to the CMD. If there's a PuTTY-like program out there that will work between me and the command line I'm happy with that - I just want a proper window to work in
I would like to parse an access log file and have returned the amount of requests, for the last 7 days. I have this command
cut -d'"' -f3 /var/log/apache/access.log | cut -d' ' -f2 | sort | uniq -c | sort -rg
Unfortunately, this command returns the amount of requests since the creation of the file and sorts it into HTTP-code categories. I would like just a number, no categories and only for the last 7 days.
Thanks.
I found that I can launch irc using command line with arguments.
The problem is that it won't join the specific channel.
This is that lunch line:
C:\Program Files\mIRC\mirc.exe /join #channel1
This command line only connects to the server, but it won't join the specific channel.
How can I connect and join a channel?
I easily can broadcast my webcam with VLC using command lines like this (I use Windows):
"C:\Program Files (x86)\VideoLAN\VLC\vlc.exe" -vvv -I --dshow-vdev="Logitech QuickCam Express / Go" dshow:// --sout
When I paste command into CMD and hit enter it starts streaming (all is fine - I can play it).
How can I now for example add brightness or any other filter to that stream from the commandline?
I easily can broadcast my webcam with VLC using command lines like this (I use Windows):
"C:\Program Files (x86)\VideoLAN\VLC\vlc.exe" -vvv -I --dshow-vdev="Logitech QuickCam Express / Go" dshow:// --sout
When I paste command into CMD and hit enter it starts streaming (all is fine - I can play it).
How can I now for example add brightness or any other filter to that stream from the commandline?
I have a Windows 2003 server running a SSH server (WRQ Reflection), how would I ssh to it and specify a specific drive letter? (like the D: drive)
ex: from another workstation: ssh [email protected] d:
When I do that it fails and I get this error: "exec request failed on channel 0" If I simply SSH to that same windowsbox without trying to specify a drive letter I get a Windows (CMD.EXE) command prompt shell on the C: drive. I can then run any windows command.
Thanks