-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.xml
131 lines (131 loc) · 14.2 KB
/
index.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>LiHong's Note</title>
<link>https://stingh711.github.io/</link>
<description>Recent content on LiHong's Note</description>
<generator>Hugo</generator>
<language>en-US</language>
<lastBuildDate>Wed, 04 Dec 2024 10:25:00 +0800</lastBuildDate>
<atom:link href="https://stingh711.github.io/index.xml" rel="self" type="application/rss+xml" />
<item>
<title>Switching From Evil to Meow</title>
<link>https://stingh711.github.io/posts/switching-from-evil-to-meow/</link>
<pubDate>Wed, 04 Dec 2024 10:25:00 +0800</pubDate>
<guid>https://stingh711.github.io/posts/switching-from-evil-to-meow/</guid>
<description>Recently I switched from evil model to meow.
Evil mode is powerful but slow. It conflits with the keybindings of some customized modes, like howm or zk&rsquo;s index mode.
Second, it is difficult to customize for my poor knowledge of elisp.
Last, I only use emacs for note taking, and I don&rsquo;t need the power of evil mode. I don&rsquo;t do complex editing, so meow is a good choice.
After read meow-tutor several times and do some customization of key mappings, I am quite happy with meow.</description>
</item>
<item>
<title>Vscode python check wrong method parameters</title>
<link>https://stingh711.github.io/posts/vscode-python-check-wrong-method-parameters/</link>
<pubDate>Fri, 11 Oct 2024 15:14:10 +0800</pubDate>
<guid>https://stingh711.github.io/posts/vscode-python-check-wrong-method-parameters/</guid>
<description>Recently I switched from pycharm to cursor which is vscode based. However, I found it cannot find errors if I pass wrong parameters to a method.
For example, I have a method like this:
def add(a, b): return a + b And then I call this method like this:
add(1) In pycharm, it will warn me that there is an unexpected argument. However, in cursor, it won&rsquo;t. After some research, I found the setting python.</description>
</item>
<item>
<title>Silverbullet.md</title>
<link>https://stingh711.github.io/posts/silver_bullet_md/</link>
<pubDate>Tue, 21 Feb 2023 00:00:00 +0000</pubDate>
<guid>https://stingh711.github.io/posts/silver_bullet_md/</guid>
<description>Today I found another note-taking application named silverbullet. It is a simple tool but with essential features.
It has only one panel, the note edit panel. (After install back link plugin, you will get a left panel to display back links) Just like a wiki, you can add new pages with [[]]. Or you can use command cmd+k to find pages by name or create a new page if the page does&rsquo;t exist.</description>
</item>
<item>
<title>Obsidian is the best note app</title>
<link>https://stingh711.github.io/posts/obsidian/</link>
<pubDate>Fri, 13 Jan 2023 00:00:00 +0000</pubDate>
<guid>https://stingh711.github.io/posts/obsidian/</guid>
<description>I&rsquo;ve tried a lot of note-taking applications, especially the so-called zettelkasten ones. From emacs&rsquo; org-roam, to tiddlywiki, to Bear, to VS Code based denron, and logseq, noteplan and craft on the mac platform, and the equally famous logseq, I&rsquo;ve tried each one a little.
UI-wise, Bear is my favorite, nothing fancy, powerful tag system, simple and easy to use. But the Bear team seems to have spent a lot of time on rewriting the editor, which doesn&rsquo;t make any sense to most users.</description>
</item>
<item>
<title>How to format Date to JSON in golang</title>
<link>https://stingh711.github.io/posts/format_date_to_json_golang/</link>
<pubDate>Wed, 31 Mar 2021 00:00:00 +0000</pubDate>
<guid>https://stingh711.github.io/posts/format_date_to_json_golang/</guid>
<description>I have a gorm model and it has a Date field. But golang doesn’t have a “pure” date struct, so we use time.Time.
type OperationPlanningResult struct { ID uint PlannedStartedAt time.Time `json:&#34;planned_started_at&#34;` } When I marshal it to JSON, this field is like “2006-01-02T00:00:00Z08” and I need to parse it again in frontend.
One way to do it is writing a custom type and providing a custom MarshalJSON function. But I need to write the relative method for gorm because I’m using gorm.</description>
</item>
<item>
<title>How to use python in ultisnips</title>
<link>https://stingh711.github.io/posts/python_ultisnips/</link>
<pubDate>Wed, 31 Mar 2021 00:00:00 +0000</pubDate>
<guid>https://stingh711.github.io/posts/python_ultisnips/</guid>
<description>This snippet uses python to convert camel case to underline. It is an example to use python in ultisnips. t[1] gets content of $1. After the convert, assign the result to snip.rv.
snippet gfk &#34;gorm foreign key&#34; $1ID uint \`gorm:&#34;column:`!p name=re.sub(r&#34;(\w)([A-Z])&#34;, r&#34;\1_\2&#34;, t[1]).lower(); snip.rv = name`_id&#34; json:&#34;-&#34;\` ${1:Model} $1 \`gorm:&#34;foreignKey:$1ID&#34; json:&#34;`!p name=re.sub(r&#34;(\w)([A-Z])&#34;, r&#34;\1_\2&#34;, t[1]).lower(); snip.rv = name`&#34;\` endsnippet </description>
</item>
<item>
<title>Django-auto-prefetching</title>
<link>https://stingh711.github.io/posts/django_auto_prefetching/</link>
<pubDate>Thu, 22 Oct 2020 00:00:00 +0000</pubDate>
<guid>https://stingh711.github.io/posts/django_auto_prefetching/</guid>
<description>Django-auto-prefetching is a small django package to do the select_related and prefetch_related automatically.
Usage The usage is very simple, just import the AutoPrefetchViewSetMixin from django_auto_prefetching, and then add the mixin as the base class of a ListAPIView
If you override the get_queryset of the ListAPIView, need some work to make it work.
import django_auto_prefetching from rest_framework.viewsets import ModelViewSet class BaseModelViewSet(django_auto_prefetching.AutoPrefetchViewSetMixin, ModelViewSet): serializer_class = YourModelSerializer def get_queryset(self): # Simply do the extra select_related / prefetch_related here # and leave the mixin to do the rest of the work queryset = YourModel.</description>
</item>
<item>
<title>Vim-projectionist</title>
<link>https://stingh711.github.io/posts/vim_projectionist/</link>
<pubDate>Thu, 16 Apr 2020 00:00:00 +0000</pubDate>
<guid>https://stingh711.github.io/posts/vim_projectionist/</guid>
<description>When working on django projects, I need to switching among django’s model, view, url, admin and serializers files. I used to use fzf.vim to jump around until I found vim-projectionist.
With this plugin, you can create a “map” of your source code, with this map, you can just from for example, .c file to .h file.
Create a .projections.json under your django file as follows:
{ &#34;*/urls.py&#34;: { &#34;type&#34;: &#34;urls&#34;, &#34;alternate&#34;: &#34;{}/views.</description>
</item>
<item>
<title>Vscode's restclient is great</title>
<link>https://stingh711.github.io/posts/vscode-restclient-is-great/</link>
<pubDate>Tue, 26 Jun 2018 00:00:00 +0000</pubDate>
<guid>https://stingh711.github.io/posts/vscode-restclient-is-great/</guid>
<description>Postman is an essential tool for the development of both frontend and backend. However, sometimes I hate its save function. I hate to find a right folder to save a request. What I need is just a very simple tool to test some API and it will be just there when I need it. Then I found REST Client extension for Vscode.
With this extension, you can save your request in plain text.</description>
</item>
<item>
<title>Use django-filter to add filter for REST api</title>
<link>https://stingh711.github.io/posts/use-django-filter-to-add-filter-for-rest-api/</link>
<pubDate>Sat, 23 Jun 2018 00:00:00 +0000</pubDate>
<guid>https://stingh711.github.io/posts/use-django-filter-to-add-filter-for-rest-api/</guid>
<description>For a REST list api, filtering and sorting is the basic requirements. Using django-filter, we can add these functions with only a few lines of codes.
For example, if we have a model as follows,
class Product(models.Model): name = models.CharField(max_length=100) created_at = models.DatetimeField() We will write relative serializer and view.
class ProductSerializer(serializers.ModelSerializer): class Meta: fields = &#39;__all__&#39; class ProductListView(generics.ListView): queryset = Product.objects.all() serializer_class = ProductSerializer If we don&rsquo;t use django-filter, we can override ProductListview&rsquo;s get_queryset to implement filter.</description>
</item>
<item>
<title>Use org-journal to keep my daily notes</title>
<link>https://stingh711.github.io/posts/use-org-journal/</link>
<pubDate>Sat, 23 Jun 2018 00:00:00 +0000</pubDate>
<guid>https://stingh711.github.io/posts/use-org-journal/</guid>
<description>org-journal is small package to write your journal in org mode. Like diary mode, it will generate one file per day, but you can use org-mode instead of plain dairy mode.
To create a journal, just press C-c c-j, an org-mode item will be created with curren time.
It is also provided calendar binding, so you can view your journal from calendar view.</description>
</item>
<item>
<title>Write a CustomPaginator for django rest framework</title>
<link>https://stingh711.github.io/posts/custom-paginator-for-drf/</link>
<pubDate>Sat, 23 Jun 2018 00:00:00 +0000</pubDate>
<guid>https://stingh711.github.io/posts/custom-paginator-for-drf/</guid>
<description>Pagination is essential part for a REST api. Django rest framework provides an easy to way to add pagination to current API and a lot of useful built-in implementations. However, in order to work with a specified frontend component, a customized version is needed.
Customizing is easy in DRF, just extends a current one and override it get_paginated_response method. For example, the following one uses the page number pagination ,which means you can pass page=n in the URL to get the nth page.</description>
</item>
<item>
<title>How to remove vscode's decorator warning?</title>
<link>https://stingh711.github.io/posts/how-to-remove-vscode-decorator-warning/</link>
<pubDate>Tue, 19 Jun 2018 00:00:00 +0000</pubDate>
<guid>https://stingh711.github.io/posts/how-to-remove-vscode-decorator-warning/</guid>
<description> Create a tsconfig.json under root directory. Add following code to tsconfig.json { &#34;compilerOptions&#34;: { &#34;experimentalDecorators&#34;: true, &#34;allowJs&#34;: true } } Restart vscode </description>
</item>
<item>
<title>Pandas in jupyter</title>
<link>https://stingh711.github.io/posts/pandas-in-jupyter/</link>
<pubDate>Sun, 17 Jun 2018 00:00:00 +0000</pubDate>
<guid>https://stingh711.github.io/posts/pandas-in-jupyter/</guid>
<description>Read data from mysql and draw a chart.
%matplotlib inline import pymysql import pandas as pd import pandas.io.sql as sql conn = pymysql.connect(host=&#39;192.168.56.1&#39;, user=&#39;root&#39;, passwd=&#39;qwer-1235&#39;, db=&#39;pdss&#39;) s = &#39;select number_value from quality_data_item_record where item_id = 11&#39; df = sql.read_sql_query(s, conn) df.plot() </description>
</item>
<item>
<title>Javascript notes</title>
<link>https://stingh711.github.io/posts/javascript-notes/</link>
<pubDate>Sat, 16 Jun 2018 00:00:00 +0000</pubDate>
<guid>https://stingh711.github.io/posts/javascript-notes/</guid>
<description>Just some notes on some popular javascript libraries.
bootstrap-daterangepicker How to get startDate and endDate var range = $(&#34;#range&#34;).daterangepicker(); var start = range.data(&#34;daterangepicker&#34;).startDate; var end = range.data(&#34;daterangepicker&#34;).endDate; lodash map var data = [ { label: &#34;4/1&#34;, value: 10 }, { label: &#34;4/2&#34;, value: 14 }, ]; var labels = _.map(data, function (item) { return item.label; }); var values = _.map(data, function (item) { return item.value; }); It is especially useful when preparing data for some chart libraries.</description>
</item>
<item>
<title>Notes about postgresql</title>
<link>https://stingh711.github.io/posts/notes-about-postgresql/</link>
<pubDate>Tue, 08 May 2018 00:00:00 +0000</pubDate>
<guid>https://stingh711.github.io/posts/notes-about-postgresql/</guid>
<description>How to generate and insert test data? For example, my table is like: create table (time timestamp, value double precision, sensor integer). If I want to insert some test data, I can use function generate_series. Following sql will insert 5000 rows:
insert into test (time, sensor, value) select now(), i, random() from generate_series(1, 5000) s(i) How to view disk usage? View table size select pg_size_pretty(pg_relation_size(&#39;pressure_01&#39;)) View database size select pg_size_pretty(pg_database_size(&#39;pressure_01&#39;)) </description>
</item>
<item>
<title>Dynamic forms with springmvc and thymeleaf</title>
<link>https://stingh711.github.io/posts/dynamic-form-with-springmvc-and-thymeleaf/</link>
<pubDate>Fri, 01 Aug 2014 00:00:00 +0000</pubDate>
<guid>https://stingh711.github.io/posts/dynamic-form-with-springmvc-and-thymeleaf/</guid>
<description>Requirements SubjectGroup and SubjectGroupOption has one-to-many relationship. When adding a subject group, subject group options can be added inline.
Things I’ve learned. When adding an option, don’t need to use javascript to handle the added html snippet. Just submit the add request to controller and handle the adding in the controller (Add a new options into the option list of subject group), then return to the add page. Spring mvc’s data binding and thyme leaf’s for loop will handle the html.</description>
</item>
</channel>
</rss>