@echo off
SET st2Path=C:\Program Files\Sublime Text 2\sublime_text.exe
rem add it for all file types
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 2" /t REG_SZ /v "" /d "Open with Sublime Text 2" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 2" /t REG_EXPAND_SZ /v "Icon" /d "%st2Path%,0" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 2\command" /t REG_SZ /v "" /d "%st2Path% \"%%1\"" /f
rem add it for folders
@reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 2" /t REG_SZ /v "" /d "Open with Sublime Text 2" /f
@reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 2" /t REG_EXPAND_SZ /v "Icon" /d "%st2Path%,0" /f
@reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 2\command" /t REG_SZ /v "" /d "%st2Path% \"%%1\"" /f
pause
LDAP server configuration on eclipse
Ok, if you are following the instruction of this for LDAP based authentication, you may want to connect to the LDAP server in eclipse and take a look of the data configured. Here are the steps to to it:
- Install apache directory studio plugin for eclipse, add url (http://directory.apache.org/studio/update) in the eclipse software update
- Create a LDAP server connection
- Click on LDAP browser, you will see the data.
You can also test on this free LDAP server with the following information:
LDAP Server Information (read-only access):
Server: ldap.forumsys.com
Port: 389
Bind DN: cn=read-only-admin,dc=example,dc=com
Bind Password: password
All user passwords are password.
You may also bind to individual Users (uid) or the two Groups (ou) that include:
ou=mathematicians,dc=example,dc=com
- riemann
- gauss
- euler
- euclid
ou=scientists,dc=example,dc=com
- einstein
- newton
- galieleo
- tesla
here is the screenshot:
Anypoint Studio – Screen Frozen at Workspace Launcher
The issue is that Anypoint Studio doesn’t support java 9, so as an alternative, you can start Anypoint Studio by using java 8 instead with this command assuming you are working on Mac.
/Applications/AnypointStudio.app/Contents/MacOS/AnypointStudio -vm /Library/java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home/bin
Thanks, https://out-of-memo.blogspot.com/2017/10/mule-anypoint-studio-screen-frozen-at.html
How to add binary data to mongoDB?
For small file of any kind, images, videos, pdf, etc, you can insert BSON data in a collection. Here is the code in stackoverflow, thanks:)
var fs = require('fs'); var mongo = require('mongodb').MongoClient; var Binary = require('mongodb').Binary; var imagepath = fs.readFileSync("test.jpg"); var image = { id: "testid" }; image.bin = Binary(imagepath); mongo.connect('mongodb://localhost:27017/local', function (err, db) { if (err) console.log(err); db.collection('IMAGES') .insert(image, function (err, doc) { if (err) console.log(err); db .collection('IMAGES') .findOne({ id: 'testid' }, function (err, doc) { if (err) { console.error(err); } fs .writeFile('myimage', doc.bin.buffer, function (err) { if (err) throw err; console.log('Sucessfully saved!'); }); }); }); });
Initial states using constructor vs getInitialState in React / React Native
In ES6 classes, you should use constructor, but in React.createClass you should use getInitialState method.
class MyComponent extends React.Component { constructor(props) { super(props); this.state = { /* initial state */ }; } } var MyComponent = React.createClass({ getInitialState() { return { /* initial state */ }; }, });
Have issue with /var/run/docker.sock in a container not running as root?
Have issue with /var/run/docker.sock in a container not running as root? There are many posts online about it and none of them is working for me. My last hope –reboot your machine actually did the job!
How to Install Nginx as a reverse proxy server
Let’s assumeyou have Nginx installed, here are the steps to set up reverse proxy server:
1. create a config file under /etc/nginx/sites-available/leespace.com
2. Change the configure by editing example.com to have the following:
server { listen 80; server_name leespace.com www.leespace.com; location /blog { proxy_pass http://localhost:88/blog; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } }
3. Create a symbolic link :
sudo ln -s /etc/nginx/sites-available/leesapce.com /etc/nginx/sites-enabled/leesapce.com
4. Restart nginx server with : service nginx restart
5. Optional step : set up your land page at /usr/share/nginx/html
Git cherry-pick from another repository
Git cherry-pick from another repository
# Cloning our fork $ git clone git clone git@gitlab.com:tongancity/Leespace-git-demo.git # Adding (as "demo2") the repo from we want to cherry-pick $ git remote add demo2 git@gitlab.com:tongancity/Leespace-git-demo2.git # Fetch their branches $ git fetch demo2 # List their commits $ git log demo2/develop # Cherry-pick the commit we need $ git cherry-pick d434sgdffedac # Pushing to our master $ git push origin develope
NgInx with Docker
You need to pull docker image for nginx first with : docker pull nginx, the following command will run nginx on docker container by exposing port 80 to the public.
sudo docker run –name docker-nginx -p 80:80 -e TERM=xterm -d nginx
go to docker local:
docker exec -it CONTAINER_ID bash