Markus Tenghamn

Programmer and Entrepreneur

Making large selections quickly in Sublime

8th of February, 2016

So tonight I was editing a large sql file, a few million lines and the import got stuck about half way through. The easiest solution would be to edit the sql dump and I needed a quick way to remove half the text in the file. At first I tried finding the line and manually selecting the lines but realized that it would take forever. So how in the world do I make large selections quickly?

Thats when I headed to Google to find the best way of doing this. After a bit of searching I stubled across a thread called Large Selection/Highlight or Select Range by Line Number . With a nice answer regarding markers in Sublime.

So basically all you have to do is scroll to the line where you want to make your selection from and click Edit->Mark->Set mark.


Then scroll to the line where you want your selection to go to and click Edit->Mark->Select to mark

Splitting huge video files that can’t be opened in Adobe Premiere

6th of February, 2016

So last night was game night and I was recording the newly released XCOM 2 with BigSwedish for several hours using OBS. OBS allows me to record on multiple audio channels so that I have myself speaking on one channel, Skype and whoever I am talking to on one channel and the actual game audio on a third channel. This makes it easier to edit in Premiere but it also makes for some very big files. This morning I wake up to begin editing my file and notice that its 40GB and importing it to Premiere either seems to freeze my computer completely or simply crash the program. Thus I realized that I needed to cut this file into smaller pieces but I had no idea what program to use. Splitting the file would not be as easy as I had hoped.

One option is to use VLC media player to record the video that is playing and use the recorded file, however this did NOT work for me as VLC did not preserve the video quality and also seemed to mess upp my audio tracks. I kept searching and tried many different programs, some programs I skipped as they seemed to be malware/spyware (Be careful when searching for free stuff). Finally looking at some forum posts got me going in the right direction to find a solution to my problem.

How I solved it

Avidemux solved all of my problems. It basically gives you the same capabilities as cutting video with premiere pro but in a much simpler interface. This program lagged for a few seconds but had no trouble loading my video file. I could also drag the slider to the needed position and set the markers for when I wanted to begin my cut and end it (just like Premiere). Once you have set your markers all you need to do is save your video and you are done! I love that Avidemux has the ability to simply copy the video and audio output. Avidemux should run fine and be perfect for splitting video on Unix, Mac or Windows. I hope this post helps some users who may be stuck with the same problems I had.

If you know of an even better way of doing video splitting please do let me know in the comments below!

Laravel and keeping my bitcoin bot running forever

23rd of January, 2016

So I was trying to figure out how to keep a script running forever as I want to constantly get social media updates and feeds from bitcoin exchanges when I use my bot to trade. Previously I would have done this with a bash script that would check for a tmp file that would be generated when the script was running and removed when it stopped, The script would be accessible as a console command in laraval making it easy to run. However, this could sometimes fail as well. I figured there must be a better way to achieve what I want to do.

I headed over to Reddit and posted my question where I have gotten a lot of help before and got a really useful answer from mbdjd. I had overlocked the cron section of the Laravel documentation that mentions the withoutOverlapping() method which would basically start my script whenever it stopped and keep it running at all times.

Bash script for new Laravel install on Ubuntu 14

23rd of January, 2016

The following is a simple script that I have used to set permissions on development builds for Laravel, it usually fixes permission issues and gets me up and running quickly. You can put it into a .sh file to run all the commands or simply copy and paste. I also have this running with git as a post-receive hook that will copy the master branch to a testing server.

mkdir bootstrap/cache/;
mkdir storage/framework/cache;
mkdir storage/framework/views;
mkdir storage/framework/sessions;
sudo chown -Rf $USER:www-data .;
sudo chmod -R o+w storage;
sudo chmod -R o+w bootstrap/cache;
sudo chown -Rf www-data:www-data bootstrap/cache;
sudo chown -Rf www-data:www-data storage;
php artisan clear-compiled;
php artisan config:clear;
php artisan optimize;
php artisan migrate;
php artisan db:seed;
sudo apt-get install npm;
sudo apt-get install node;
npm install gulp; 
npm install laravel-elixir; 
sudo gulp;

Bitcoin bot

22nd of January, 2016

So tonight I took a little break to work on an idea that I have had for a while. Initially I wanted to look at social media, analyze the text to try to put a positive or negative number which would hopefully give an indication on where the stock price would go. Now tracking stocks can be complicated due to delays in APIs and things like that and you would also need to decide on which stocks to pick. I guess this turned me off a bit as I wanted to make something quick and simple that would give me results. That gave me the idea of trying something different like bitcoin (also litecoin and dogecoin because why not?). What if I could use my bot to predict when the price of bitcoin would go up or down, a simple bitcoin bot? I could very easily get several indicators for my bot and then tell it when to buy or sell. Tonight I got started on the bot which currently gets a live feed of every single tweet metioning bitcoin as a live feed, check it out 😀

Bitcoin twitter live feed

Bitcoin twitter live feed

I can now build a dictionary for positive and negative words which I can then compare and tweak to try to match the price. I also thought of two more indicators while I worked on this which are the amount of tweets (popularity) and also the amount of transactions (buys and sells, aka demand). Hopefully this project can turn into something useful and be a start for a similar bot that predicts stock prices.

Why Online Advertising Should Listen To The User

20th of January, 2016

Online advertising is a very one sided market with all emphasis being put on the companies that need a quick way to reach users but almost no thought is put on the user. Of course it is not the companies responsibility in mind, unless they manually put their adverts on websites, it is up to the ad networks. There are many ad networks out there, the biggest being Google Adwords. Now the only way for a user to give feedback about an ad is to search through Google’s help pages which is nowhere near easy.

So what’s the problem with online advertising?

Sure, online advertising has been around for a long time, over 30 years if wikipedia is correct. Eventually all the ads became too much for users, especially with javascript and flash animations that sometimes included sound. Oh and don’t even get me started on malware and viruses that have been spread through online ads. This abuse by companies has led users to create and use adblockers such as Adblock Plus which even I use with the exception of websites that I trust and go to often. This leads to big losses for companies that earn money through advertising which is unfortunate, I personally feel bad when blocking ads on some sites but I don’t want it to ruin my experience and I do not want to risk getting malware if I can prevent it.

So how do we solve this problem?

Ad networks need to start listening to the user more which would be very easy to do and it would probably give companies a better return. Users can help companies advertise in a way that is fair to the user and that won’t annoy them. A rating system could be implemented for ads which would be based on certain criteria. You could also have different categories to allow for different kinds of ads. I’m sure Google could even get more registered users as a registered account might be needed to set the rating of ads you want to see. For example I might choose to only see ads that are static images and hide anything with animations or sounds. This creates a better experience for myself, I might even like the ads being presented, I will also support the sites that I visit and the companies that do the advertising are happy that they can reach a wider audience. With the rating system in place the companies could also get great feedback on what users love and hate and some users might even give useful ideas on how to improve conversion rates on ads. Users could have some kind of point system to reward them depending on how active and accurate they are in their ratings, similar to how the rating system on Stack Overflow works.

Time to change the website a bit

16th of January, 2016

About 6 months ago I accepted a great job at Key Solutions here in Västerås, Sweden where I live which has kept me pretty busy lately. I don’t have time to write as much as I did before and and the time has also given me time to think about what I really want to publish here. The blog will be more personal from now on and less promotional. I want to share random thoughts and ideas that I have during the day which might result in some shorter posts. I also want to share my knowledge and solutions and perhaps contribute a bit to open source libraries when I get the chance. As you may have noticed my blog has a much cleaner and simpler look which I love, it looked messy in the past. Anyways to get started with the new blog let’s take a look at some of my interesting projects which are free to use and open sourced.

You have the iOS app that I created for my blog which simply reads my rss feed and publishes it in the app. It is available on the app store, simply search for “Markus Tenghamn” and you will find it. The complete source code can be found on github here:

Oh and feel free to follow me on Github here and ping me if you want me to take a look at an interesting project.

Recently I also made my first real contribution to a Github project, it’s not much but if anyone needs Swedish localization for carbon on laravel you will find it here

Anyways, currently I am messing around with nodejs, redis and beanstalk to get a laravel installation working, I’m sure I will have something to say about it soon so stay tuned for more interesting posts.

Anveto Push Notifications

Anveto Push Notifications For WordPress

31st of March, 2015

My latest plugin made via Anveto stores tokens from apps that can then be used to send push notifications. My idea was to create this plugin and store tokens in order to add more functions to it later such as exporting the tokens to csv format or sending push notifications directly from wordpress whenever a new post is added on my blog.

You can find the plugin here

UberChat Wordpress Plugin

UberChat for WordPress with Windows Client [Review] [Video]

30th of March, 2015

Today I will be reviewing UberChat for WordPress with Windows Client which is a really nice live chat support plugin. You can find the plugin on CodeCanyon by following this link.

You can also watch my video review on Youtube by clicking here.

Let’s get started! The plugin comes with a lot of clear documentation, however the first step is pretty easy. We need to upload our plugin either by using an FTP program like Filezilla or by simply using the standard add plugin form on your WordPress site. Then activate the plugin and make sure you don’t see any errors.

When this is done your should see the UberChat menu on the left hand side inside your WordPress installation. Take a look at the settings page to make sure everything looks correct. For example you may want to change the email that will be used or the categories/pages where your chat box will show. If everything looks good simply head over to your Dashboard, in the top right corner you will see a button called “Go Online”. Once this is clicked you will go live. This was the only problem I had with the plugin, when online the “Go offline” button has an animated gif which makes it looks like it is trying to load something. After a short time I realized that it was simply something that indicated that I was online. Perhaps there is a better way of showing that the user is online.

Once you are active you can test the chat by going to another tab or opening a different browser. The addon seems to use gravatars for users profile pictures. While you are active in the dashboard you will also see that you can see what visitors are currently visiting the site and where they are from. One of the unique things with this addon is the ability to invite users to chat.

If you look on the left side you will also see that the plugin allows you to see chat logs of previous sessions and form submissions for when the live chat is inactive. You can also setup canned responses. These automated responses can be used while in the chat to send standard messages such as a “welcome, how can I help you?” when the user first enters the chat or answers to common problems that users may have such as finding their way to the checkout page.

This plugin also includes a windows chat application which will connect to your WordPress installation and allow you to chat with users without having to have a browser open. In order to set this up you will need the API-Key from your UberChat settings page inside your WordPress installation. You will also need to provide a username and password for the user who will be chatting to other users. To begin setup navigate to the Windows Client folder and find the .exe file to begin setup. The setup was easy and pretty self explanatory. Once that is done you should find UberChat in your windows start menu. When opened the first time you will need to enter your CodeCanyon username and purchase code which you can get from CodeCanyon in the downloads section of your profile. Once this is done you will be promted to enter the API key from your UberChat settings area and the login information of the user who should act as the support operator. You can also select from settings such as language, theme and notification sounds. Once logged in you will see the same layout as you did in your dashboard. When a user begins a chat it will pop up in your windows application and you can begin chatting.

Need help installing this plugin? Experts at Anveto can install and configure this plugin for you quickly, please click here to read more and order.

Overall I think the plugin is really great. It seems to run smoother and faster than other live chat support scripts and has all of the basic features. I hope more features will be added in the future as the author of the plugin has created many similar scripts and seems to be an active developer.