-
Notifications
You must be signed in to change notification settings - Fork 0
/
atom.xml
990 lines (847 loc) · 51 KB
/
atom.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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title><![CDATA[povess notes]]></title>
<link href="http://bluengreen.github.io/atom.xml" rel="self"/>
<link href="http://bluengreen.github.io/"/>
<updated>2013-09-21T18:19:28-05:00</updated>
<id>http://bluengreen.github.io/</id>
<author>
<name><![CDATA[Phillip Novess]]></name>
</author>
<generator uri="http://octopress.org/">Octopress</generator>
<entry>
<title type="html"><![CDATA[DRY up your controllers with base controllers]]></title>
<link href="http://bluengreen.github.io/blog/2013/09/21/cleanup-rails-controllers-with-base-controllers/"/>
<updated>2013-09-21T04:44:00-05:00</updated>
<id>http://bluengreen.github.io/blog/2013/09/21/cleanup-rails-controllers-with-base-controllers</id>
<content type="html"><![CDATA[<p>Controllers are just basic ruby classes that inherit from ActionController::Base. This means you can manage your controllers just as you would manage a ruby class. DRY up your controllers by moving supporting methods into a base controller.</p>
<!-- more -->
<p>Obviously, we can move methods into the Application controller. But we may not need these methods across the whole application. A perfect example of this is when we are creating a site that has public and private sections of the site.</p>
<p>Example 1:</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="k">class</span> <span class="nc">ApplicationController</span> <span class="o"><</span> <span class="ss">ActionController</span><span class="p">:</span><span class="ss">:Base</span>
</span><span class='line'> <span class="n">before_filter</span> <span class="ss">:authenticate_user!</span>
</span><span class='line'>
</span><span class='line'> <span class="c1"># other methods </span>
</span><span class='line'><span class="k">end</span>
</span></code></pre></td></tr></table></div></figure>
<p></p>
<p>The problem with this is we would have to do a skip_before_filter on every controller we want public. Or conversely we would have to call the before_filter on all private pages.</p>
<p>I prefer to create a namespace for the private sections by creating a directory in Rails root app/controllers. Let’s call this directory admin. Then create a new controller within the admin directory for users.</p>
<p>Example 2:</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="k">class</span> <span class="nc">Admin</span><span class="o">::</span><span class="no">UsersController</span> <span class="o"><</span> <span class="ss">ActionController</span><span class="p">:</span><span class="ss">:Base</span>
</span><span class='line'> <span class="n">before_filter</span> <span class="ss">:authenticate_user!</span>
</span><span class='line'>
</span><span class='line'> <span class="c1"># other methods </span>
</span><span class='line'><span class="k">end</span>
</span></code></pre></td></tr></table></div></figure>
<p>Now we can access the protected controller by going to <a href="http://localhost:3000/admin/users">http://localhost:3000/admin/users</a> But now we still have to apply a before_filter on any added controllers within admin. I think a better way to handle this is to create a base controller within the admin directory that the admin controllers can inherit from.</p>
<p>Example 3:</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="k">class</span> <span class="nc">Admin</span><span class="o">::</span><span class="no">BaseController</span> <span class="o"><</span> <span class="ss">ActionController</span><span class="p">:</span><span class="ss">:Base</span>
</span><span class='line'> <span class="n">before_filter</span> <span class="ss">:authenticate_user!</span>
</span><span class='line'>
</span><span class='line'> <span class="c1"># other methods </span>
</span><span class='line'><span class="k">end</span>
</span><span class='line'>
</span><span class='line'><span class="k">class</span> <span class="nc">Admin</span><span class="o">::</span><span class="no">UsersController</span> <span class="o"><</span> <span class="ss">Admin</span><span class="p">:</span><span class="ss">:BaseController</span>
</span><span class='line'> <span class="c1"># other methods </span>
</span><span class='line'><span class="k">end</span>
</span></code></pre></td></tr></table></div></figure>
<p>This has the added benefit of being able to add any methods that can be used across the admin in a shared controller.</p>
<p>However, there is no reason we must limit ourselves to only the admin. I find many times I have methods I need to use across specific controllers. This is a perfect opportunity to DRY up those controllers, by namespacing and creating a base controller.</p>
<p>Example 4:</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="k">class</span> <span class="nc">Reports</span><span class="o">::</span><span class="no">BaseController</span> <span class="o"><</span> <span class="ss">ActionController</span><span class="p">:</span><span class="ss">:Base</span>
</span><span class='line'> <span class="c1"># methods for all reports </span>
</span><span class='line'><span class="k">end</span>
</span><span class='line'>
</span><span class='line'><span class="k">class</span> <span class="nc">Reports</span><span class="o">::</span><span class="no">StandardController</span> <span class="o"><</span> <span class="ss">Reports</span><span class="p">:</span><span class="ss">:BaseController</span>
</span><span class='line'> <span class="c1"># other methods </span>
</span><span class='line'><span class="k">end</span>
</span><span class='line'>
</span><span class='line'><span class="k">class</span> <span class="nc">Reports</span><span class="o">::</span><span class="no">CustomController</span> <span class="o"><</span> <span class="ss">Reports</span><span class="p">:</span><span class="ss">:BaseController</span>
</span><span class='line'> <span class="c1"># other methods </span>
</span><span class='line'><span class="k">end</span>
</span></code></pre></td></tr></table></div></figure>
<p></p>
<p>This is nothing groundbreaking or revolutionary. But like many things in ruby and Rails, simple and basic saves the day.</p>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[MySQL Setup replication]]></title>
<link href="http://bluengreen.github.io/blog/2013/09/21/mysql-setup-replication/"/>
<updated>2013-09-21T04:41:00-05:00</updated>
<id>http://bluengreen.github.io/blog/2013/09/21/mysql-setup-replication</id>
<content type="html"><![CDATA[<p>Here are the basic steps for setting up mysql replication on rackspace CloudServers using a RHEL/Centos distribution of linux.</p>
<!-- more -->
<h2>MASTER SERVER CONFIGURATION</h2>
<p>Setup firewall rules on the master database server to accept incoming requests from the internal network card attached to your CloudServer instance. This is assuming that the slave database server is also a rackspace CloudServer and within the same region.</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'><span class="c"># firewall rules for master</span>
</span><span class='line'><span class="c"># allows the slave servers to connect to the master </span>
</span><span class='line'><span class="c"># via rackspace servicenet</span>
</span><span class='line'>iptables -A INPUT -i eth1 -p tcp --dport 3306 -m state --state NEW,ESTABLISHED -j ACCEPT
</span><span class='line'>iptables -A OUTPUT -o eth1 -p tcp --sport 3306 -m state --state ESTABLISHED -j ACCEPT
</span><span class='line'>service iptables save
</span></code></pre></td></tr></table></div></figure>
<p>Configure the master mysql database server. On a RHEL/Centos linux distro the mysql configuration file is in /etc. Below is an example configuration. The add the settings under the master setup section. The most important of these are the server-id and the log-bin. Every server needs a server-id. Mysql uses the log-bin to sync the slave servers.</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'><span class="c"># configure mysql conf file for replication</span>
</span><span class='line'>sudo vi /etc/my.cnf
</span><span class='line'>
</span><span class='line'>
</span><span class='line'><span class="o">[</span>mysqld<span class="o">]</span>
</span><span class='line'><span class="nv">datadir</span><span class="o">=</span>/var/lib/mysql
</span><span class='line'><span class="nv">socket</span><span class="o">=</span>/var/lib/mysql/mysql.sock
</span><span class='line'><span class="nv">user</span><span class="o">=</span>mysql
</span><span class='line'>
</span><span class='line'><span class="c"># master setup</span>
</span><span class='line'>server-id<span class="o">=</span>1
</span><span class='line'>log-bin<span class="o">=</span>master-bin.log
</span><span class='line'><span class="nv">innodb_flush_log_at_trx_commit</span><span class="o">=</span>1
</span><span class='line'><span class="nv">sync_binlog</span><span class="o">=</span>1
</span><span class='line'><span class="nv">binlog_do_db</span><span class="o">=</span>mydb
</span><span class='line'>
</span><span class='line'><span class="c"># Disabling symbolic-links is recommended to prevent assorted security risks</span>
</span><span class='line'>symbolic-links<span class="o">=</span>0
</span><span class='line'><span class="o">[</span>mysqld_safe<span class="o">]</span>
</span><span class='line'>log-error<span class="o">=</span>/var/log/mysqld.log
</span><span class='line'>pid-file<span class="o">=</span>/var/run/mysqld/mysqld.pid
</span></code></pre></td></tr></table></div></figure>
<p>Next, we have to create a user for the slave servers to use to login and connect to the database server.</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'><span class="c"># start the mysql client</span>
</span><span class='line'>mysql -uroot -p<span class="s1">'rootpassword'</span>
</span><span class='line'>
</span><span class='line'><span class="c"># create the replication user in mysql </span>
</span><span class='line'>> GRANT REPLICATION SLAVE ON *.* TO <span class="s1">'replication_user'</span>@<span class="s1">'10.1.1.2'</span> IDENTIFIED BY <span class="s1">'<your password>'</span>;
</span><span class='line'>> FLUSH PRIVILEGES;
</span></code></pre></td></tr></table></div></figure>
<p>Now show the status and get the current log and position of the master database server.<br/>
If your are on a very active database server. You will have additional steps stopping locks and writes. However, for the purpose of this setup we will assume you dont have any activity yet.</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'><span class="c"># show status and grab log and position</span>
</span><span class='line'>> SHOW MASTER STATUS;
</span></code></pre></td></tr></table></div></figure>
<h2>SLAVE SERVER CONFIGURATION</h2>
<p>Now with the master setup and the log and position of the master database we can now configure our slave database server.</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'><span class="c">######################################### </span>
</span><span class='line'><span class="c"># configure slave my.cnf </span>
</span><span class='line'>
</span><span class='line'><span class="o">[</span>mysqld<span class="o">]</span>
</span><span class='line'>server-id<span class="o">=</span>2
</span><span class='line'>master-host<span class="o">=</span>10.1.1.1
</span><span class='line'>master-user<span class="o">=</span>replication_user
</span><span class='line'>master-password<span class="o">=</span><your password>
</span><span class='line'>master-connect-retry<span class="o">=</span>60
</span><span class='line'>replicate-do-db<span class="o">=</span>mydb
</span></code></pre></td></tr></table></div></figure>
<p>Verify you can connect to the master server by using the mysql client on the slave server.</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'><span class="c">#########################################</span>
</span><span class='line'><span class="c"># verify you can connect to the master</span>
</span><span class='line'>
</span><span class='line'>mysql -h 10.1.1.1 -u repl -p<span class="s1">'<your replication user password>'</span>
</span><span class='line'>> <span class="nb">exit</span>
</span></code></pre></td></tr></table></div></figure>
<p>If that was successful we can login to the local mysql database server on the slave server and start the replication. If you weren’t able to login to the master database server from the slave server double check your firewall rules and user settings in the master database server.</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'>mysql -uroot -p<span class="s1">'rootpassword'</span>
</span><span class='line'>
</span><span class='line'><span class="c"># change master to start replication </span>
</span><span class='line'>> SLAVE STOP;
</span><span class='line'>> CHANGE MASTER TO <span class="nv">MASTER_HOST</span><span class="o">=</span><span class="s1">'10.1.1.1'</span>,
</span><span class='line'>> <span class="nv">MASTER_USER</span><span class="o">=</span><span class="s1">'replication_user'</span>,
</span><span class='line'>> <span class="nv">MASTER_PASSWORD</span><span class="o">=</span><span class="s1">'<your password>'</span>,
</span><span class='line'>> <span class="nv">MASTER_LOG_FILE</span><span class="o">=</span><span class="s1">'master-bin.000003'</span>,
</span><span class='line'>> <span class="nv">MASTER_LOG_POS</span><span class="o">=</span>106;
</span><span class='line'>>START SLAVE;
</span><span class='line'>>SHOW SLAVE STATUS<span class="se">\G</span>;
</span></code></pre></td></tr></table></div></figure>
<p>If all is successful. You should see a screen like this.</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
<span class='line-number'>23</span>
<span class='line-number'>24</span>
<span class='line-number'>25</span>
<span class='line-number'>26</span>
<span class='line-number'>27</span>
<span class='line-number'>28</span>
<span class='line-number'>29</span>
<span class='line-number'>30</span>
<span class='line-number'>31</span>
<span class='line-number'>32</span>
<span class='line-number'>33</span>
<span class='line-number'>34</span>
<span class='line-number'>35</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'>SHOW SLAVE STATUS<span class="se">\G</span>;
</span><span class='line'>*************************** 1. row ***************************
</span><span class='line'> Slave_IO_State: Waiting <span class="k">for </span>master to send event
</span><span class='line'> Master_Host: 10.176.41.72
</span><span class='line'> Master_User: repl
</span><span class='line'> Master_Port: 3306
</span><span class='line'> Connect_Retry: 60
</span><span class='line'> Master_Log_File: mysql-bin.000003
</span><span class='line'> Read_Master_Log_Pos: 314
</span><span class='line'> Relay_Log_File: mysqld-relay-bin.000003
</span><span class='line'> Relay_Log_Pos: 235
</span><span class='line'> Relay_Master_Log_File: mysql-bin.000003
</span><span class='line'> Slave_IO_Running: Yes
</span><span class='line'> Slave_SQL_Running: Yes
</span><span class='line'> Replicate_Do_DB:
</span><span class='line'> Replicate_Ignore_DB:
</span><span class='line'> Replicate_Do_Table:
</span><span class='line'> Replicate_Ignore_Table:
</span><span class='line'> Replicate_Wild_Do_Table:
</span><span class='line'>Replicate_Wild_Ignore_Table:
</span><span class='line'> Last_Errno: 0
</span><span class='line'> Last_Error:
</span><span class='line'> Skip_Counter: 0
</span><span class='line'> Exec_Master_Log_Pos: 314
</span><span class='line'> Relay_Log_Space: 235
</span><span class='line'> Until_Condition: None
</span><span class='line'> Until_Log_File:
</span><span class='line'> Until_Log_Pos: 0
</span><span class='line'> Master_SSL_Allowed: No
</span><span class='line'> Master_SSL_CA_File:
</span><span class='line'> Master_SSL_CA_Path:
</span><span class='line'> Master_SSL_Cert:
</span><span class='line'> Master_SSL_Cipher:
</span><span class='line'> Master_SSL_Key:
</span><span class='line'> Seconds_Behind_Master: 0
</span></code></pre></td></tr></table></div></figure>
<h2>Reference</h2>
<p><a href="http://www.rackspace.com/knowledge_center/article/mysql-replication-masterslave">Rackspace Knowledgebase</a></p>
<p><a href="http://dev.mysql.com/doc/refman/5.6/en/replication-howto.html">MySQL Documentation</a></p>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[MySQL Cheatsheet]]></title>
<link href="http://bluengreen.github.io/blog/2013/09/21/mysql-cheatsheet/"/>
<updated>2013-09-21T04:41:00-05:00</updated>
<id>http://bluengreen.github.io/blog/2013/09/21/mysql-cheatsheet</id>
<content type="html"><![CDATA[<p>My MySQL cheatsheet. Stuff I find myself needing but never remembering. :)</p>
<!-- more -->
<h2>Backup</h2>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class=''><span class='line'># one database
</span><span class='line'>$ mysqldump -h localhost -u root -pmypassword databasename > dumpfile.sql</span></code></pre></td></tr></table></div></figure>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class=''><span class='line'># all databases
</span><span class='line'>$ mysqldump -h localhost -u root -pmypassword --all-databases > dumpfile.sql
</span></code></pre></td></tr></table></div></figure>
<h2>Restore</h2>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class=''><span class='line'># restore one database
</span><span class='line'>$ mysql -u root -pmypassword databasename < dumpfile.sql</span></code></pre></td></tr></table></div></figure>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class=''><span class='line'># restore all databases
</span><span class='line'>$ mysql -u root -pmypassword < dumpfile.sql</span></code></pre></td></tr></table></div></figure>
<h2>Set admin password</h2>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>$ mysqladmin -u root password newpassword</span></code></pre></td></tr></table></div></figure>
<h2>Change user password</h2>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>$ mysql -u root -p
</span><span class='line'>mysql> SET PASSWORD FOR 'user'@'hostname'=PASSWORD('passwordhere');
</span><span class='line'>mysql> FLUSH PRIVILEGES;</span></code></pre></td></tr></table></div></figure>
<h2>Recover root password</h2>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>$ mysql.server stop
</span><span class='line'>$ mysqld_safe --skip-grant-tables &
</span><span class='line'>$ mysql -u root
</span><span class='line'>mysql> USE mysql;
</span><span class='line'>mysql> UPDATE USER SET password=PASSWORD("newrootpassword") WHERE User='root';
</span><span class='line'>mysql> FLUSH PRIVILEGES;
</span><span class='line'>mysql> exit
</span><span class='line'># mysql.server stop
</span><span class='line'># mysql.server start</span></code></pre></td></tr></table></div></figure>
<p><a href="http://dev.mysql.com/doc/refman/5.6/en/">MySQL Documentation</a></p>
<p><a href="http://dev.mysql.com/doc/refman/5.6/en/mysqldump.html">MySQL mysqldump reference</a></p>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[Mac OSX 10.8 Rails installation]]></title>
<link href="http://bluengreen.github.io/blog/2013/09/21/mac-osx-10-dot-8-rails-installation/"/>
<updated>2013-09-21T04:36:00-05:00</updated>
<id>http://bluengreen.github.io/blog/2013/09/21/mac-osx-10-dot-8-rails-installation</id>
<content type="html"><![CDATA[<h2>Dev workstation setup</h2>
<p>These instructions are for Mac OSX 10.8 Mountain Lion. Following these instructions will prepare your workstation for developing in Ruby on Rails.</p>
<!-- more -->
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
<span class='line-number'>23</span>
<span class='line-number'>24</span>
<span class='line-number'>25</span>
<span class='line-number'>26</span>
<span class='line-number'>27</span>
<span class='line-number'>28</span>
<span class='line-number'>29</span>
<span class='line-number'>30</span>
<span class='line-number'>31</span>
<span class='line-number'>32</span>
<span class='line-number'>33</span>
<span class='line-number'>34</span>
<span class='line-number'>35</span>
<span class='line-number'>36</span>
<span class='line-number'>37</span>
<span class='line-number'>38</span>
<span class='line-number'>39</span>
<span class='line-number'>40</span>
<span class='line-number'>41</span>
<span class='line-number'>42</span>
<span class='line-number'>43</span>
<span class='line-number'>44</span>
<span class='line-number'>45</span>
<span class='line-number'>46</span>
<span class='line-number'>47</span>
<span class='line-number'>48</span>
<span class='line-number'>49</span>
<span class='line-number'>50</span>
<span class='line-number'>51</span>
<span class='line-number'>52</span>
<span class='line-number'>53</span>
<span class='line-number'>54</span>
<span class='line-number'>55</span>
<span class='line-number'>56</span>
<span class='line-number'>57</span>
<span class='line-number'>58</span>
<span class='line-number'>59</span>
<span class='line-number'>60</span>
<span class='line-number'>61</span>
<span class='line-number'>62</span>
<span class='line-number'>63</span>
<span class='line-number'>64</span>
<span class='line-number'>65</span>
<span class='line-number'>66</span>
<span class='line-number'>67</span>
<span class='line-number'>68</span>
<span class='line-number'>69</span>
<span class='line-number'>70</span>
<span class='line-number'>71</span>
<span class='line-number'>72</span>
<span class='line-number'>73</span>
<span class='line-number'>74</span>
<span class='line-number'>75</span>
<span class='line-number'>76</span>
<span class='line-number'>77</span>
<span class='line-number'>78</span>
<span class='line-number'>79</span>
<span class='line-number'>80</span>
<span class='line-number'>81</span>
<span class='line-number'>82</span>
<span class='line-number'>83</span>
<span class='line-number'>84</span>
<span class='line-number'>85</span>
<span class='line-number'>86</span>
<span class='line-number'>87</span>
<span class='line-number'>88</span>
<span class='line-number'>89</span>
<span class='line-number'>90</span>
<span class='line-number'>91</span>
<span class='line-number'>92</span>
<span class='line-number'>93</span>
<span class='line-number'>94</span>
<span class='line-number'>95</span>
<span class='line-number'>96</span>
<span class='line-number'>97</span>
<span class='line-number'>98</span>
<span class='line-number'>99</span>
<span class='line-number'>100</span>
<span class='line-number'>101</span>
<span class='line-number'>102</span>
<span class='line-number'>103</span>
<span class='line-number'>104</span>
<span class='line-number'>105</span>
<span class='line-number'>106</span>
<span class='line-number'>107</span>
<span class='line-number'>108</span>
<span class='line-number'>109</span>
<span class='line-number'>110</span>
<span class='line-number'>111</span>
<span class='line-number'>112</span>
<span class='line-number'>113</span>
<span class='line-number'>114</span>
<span class='line-number'>115</span>
<span class='line-number'>116</span>
<span class='line-number'>117</span>
<span class='line-number'>118</span>
<span class='line-number'>119</span>
<span class='line-number'>120</span>
<span class='line-number'>121</span>
<span class='line-number'>122</span>
<span class='line-number'>123</span>
<span class='line-number'>124</span>
<span class='line-number'>125</span>
<span class='line-number'>126</span>
<span class='line-number'>127</span>
<span class='line-number'>128</span>
<span class='line-number'>129</span>
<span class='line-number'>130</span>
<span class='line-number'>131</span>
<span class='line-number'>132</span>
<span class='line-number'>133</span>
<span class='line-number'>134</span>
<span class='line-number'>135</span>
<span class='line-number'>136</span>
<span class='line-number'>137</span>
<span class='line-number'>138</span>
<span class='line-number'>139</span>
<span class='line-number'>140</span>
<span class='line-number'>141</span>
<span class='line-number'>142</span>
<span class='line-number'>143</span>
<span class='line-number'>144</span>
<span class='line-number'>145</span>
<span class='line-number'>146</span>
<span class='line-number'>147</span>
<span class='line-number'>148</span>
<span class='line-number'>149</span>
<span class='line-number'>150</span>
<span class='line-number'>151</span>
<span class='line-number'>152</span>
<span class='line-number'>153</span>
<span class='line-number'>154</span>
<span class='line-number'>155</span>
<span class='line-number'>156</span>
<span class='line-number'>157</span>
<span class='line-number'>158</span>
<span class='line-number'>159</span>
<span class='line-number'>160</span>
<span class='line-number'>161</span>
<span class='line-number'>162</span>
<span class='line-number'>163</span>
<span class='line-number'>164</span>
<span class='line-number'>165</span>
<span class='line-number'>166</span>
<span class='line-number'>167</span>
<span class='line-number'>168</span>
<span class='line-number'>169</span>
<span class='line-number'>170</span>
<span class='line-number'>171</span>
<span class='line-number'>172</span>
<span class='line-number'>173</span>
<span class='line-number'>174</span>
<span class='line-number'>175</span>
<span class='line-number'>176</span>
<span class='line-number'>177</span>
<span class='line-number'>178</span>
<span class='line-number'>179</span>
<span class='line-number'>180</span>
<span class='line-number'>181</span>
<span class='line-number'>182</span>
<span class='line-number'>183</span>
<span class='line-number'>184</span>
<span class='line-number'>185</span>
<span class='line-number'>186</span>
<span class='line-number'>187</span>
<span class='line-number'>188</span>
<span class='line-number'>189</span>
<span class='line-number'>190</span>
<span class='line-number'>191</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>
</span><span class='line'> Mac OS X 10.8 installation steps
</span><span class='line'>
</span><span class='line'>#====================================================================================
</span><span class='line'># ** many commands require sudo but many do not
</span><span class='line'># ** this installation documentation is meant to describe a user level install
</span><span class='line'># ** where sudo is needed it is explicitly referenced
</span><span class='line'># ** pay attention to not add sudo where it is NOT listed
</span><span class='line'># ** it will affect the permissions negatively
</span><span class='line'>#====================================================================================
</span><span class='line'>
</span><span class='line'># prepare mac for installations and configuration
</span><span class='line'># changes have been made to 10.8, that require
</span><span class='line'># modification in order to configure the way we want
</span><span class='line'>
</span><span class='line'># make the ~/Library directory visible so we can move bbedit customizations into it
</span><span class='line'>chflags nohidden ~/Library/
</span><span class='line'>
</span><span class='line'># make directories for our projects
</span><span class='line'>mkdir -p ~/Sites/shared/
</span><span class='line'>
</span><span class='line'># install xcode - needed for compilers and command line tools
</span><span class='line'># **this requires an apple developer account
</span><span class='line'># use the App Store app
</span><span class='line'>
</span><span class='line'># run the installer - the commandline tools contain the compilers
</span><span class='line'># install the command line tools from within the xcode application
</span><span class='line'># from xode menu select preferences then select downloads tab, install commandline tools
</span><span class='line'>
</span><span class='line'>
</span><span class='line'># ** Apple no longer ships an x client, which is required for certain libs being compiled
</span><span class='line'># ** install xquartz to meet these requuirements
</span><span class='line'>http://static.macosforge.org/xquartz/downloads/SL/XQuartz-2.7.2.dmg
</span><span class='line'>
</span><span class='line'>
</span><span class='line'># install homebrew - http://mxcl.github.com/homebrew/
</span><span class='line'>ruby <(curl -fsSkL raw.github.com/mxcl/homebrew/go)
</span><span class='line'>
</span><span class='line'># check brew config
</span><span class='line'>brew doctor
</span><span class='line'>
</span><span class='line'># update brew
</span><span class='line'>brew update
</span><span class='line'>
</span><span class='line'># install packages
</span><span class='line'>brew tap homebrew/dupes
</span><span class='line'>brew install wget
</span><span class='line'>brew install git
</span><span class='line'>brew install autoconf automake apple-gcc42
</span><span class='line'>brew install ghostscript
</span><span class='line'>brew install imagemagick
</span><span class='line'>brew install mutt
</span><span class='line'>brew install node
</span><span class='line'>brew install redis
</span><span class='line'>brew install bash-completion
</span><span class='line'>
</span><span class='line'>brew install bash-completion
</span><span class='line'>
</span><span class='line'># configure git
</span><span class='line'>git config --global color.ui true
</span><span class='line'>git config --global core.editor bbedit
</span><span class='line'>git config --global color.branch auto
</span><span class='line'>git config --global color.diff auto
</span><span class='line'>git config --global color.status auto
</span><span class='line'>
</span><span class='line'>
</span><span class='line'># create new github account for user @ http://github.com
</span><span class='line'>
</span><span class='line'># create keys for new computer / user
</span><span class='line'> ssh-keygen -t rsa -C "<your_email>"
</span><span class='line'> pbcopy < ~/.ssh/id_rsa.pub
</span><span class='line'>
</span><span class='line'># copy new keys to new user account @ http://github.com
</span><span class='line'>https://help.github.com/articles/generating-ssh-keys
</span><span class='line'>
</span><span class='line'># install mysql
</span><span class='line'>brew install mysql
</span><span class='line'>unset TMPDIR
</span><span class='line'>mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp
</span><span class='line'>mysql.server start
</span><span class='line'>
</span><span class='line'># make mysql start automatically (optional)
</span><span class='line'>mkdir -p ~/Library/LaunchAgents
</span><span class='line'>cp /usr/local/Cellar/mysql/5.6.12/homebrew.mxcl.mysql.plist ~/Library/LaunchAgents/
</span><span class='line'>launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
</span><span class='line'>
</span><span class='line'>
</span><span class='line'># set mysql password
</span><span class='line'>mysqladmin -u root password NEWPASSWORD
</span><span class='line'>
</span><span class='line'>
</span><span class='line'># install RVM and rubies
</span><span class='line'>curl -L https://get.rvm.io | bash -s stable --ruby
</span><span class='line'>rvm requirements
</span><span class='line'>
</span><span class='line'># may or may not need these commands
</span><span class='line'># depending on your system
</span><span class='line'># rvm pkg install openssl
</span><span class='line'># export CPPFLAGS=-I/opt/X11/include
</span><span class='line'># CC=/usr/local/bin/gcc-4.2 rvm reinstall 1.8.7
</span><span class='line'># CC=/usr/local/bin/gcc-4.2 rvm install 1.9.3
</span><span class='line'>
</span><span class='line'># install ruby
</span><span class='line'>rvm install 1.9.3
</span><span class='line'>
</span><span class='line'># use this ruby as default and create gemset
</span><span class='line'>rvm use 1.9.3@lin --create --default
</span><span class='line'>
</span><span class='line'>
</span><span class='line'># create and edit .bash_profile for your environment
</span><span class='line'>
</span><span class='line'>cat > ~/.bash_profile <<-ENDOFMESSAGE
</span><span class='line'>
</span><span class='line'>#############################################
</span><span class='line'># GIT completions & highlighted prompt
</span><span class='line'>#############################################
</span><span class='line'>
</span><span class='line'>if [ -f `brew --prefix`/etc/bash_completion ]; then
</span><span class='line'> . `brew --prefix`/etc/bash_completion
</span><span class='line'>fi
</span><span class='line'>
</span><span class='line'>GIT_PS1_SHOWDIRTYSTATE=true
</span><span class='line'>PS1='\[\033[32m\]\u@\h\[\033[00m\]:\[\033[34m\]\w\[\033[31m\]$(__git_ps1)\[\033[00m\]\$ '
</span><span class='line'>
</span><span class='line'>
</span><span class='line'>#############################################
</span><span class='line'># Bash ls colors
</span><span class='line'>#############################################
</span><span class='line'>
</span><span class='line'>export CLICOLOR=1
</span><span class='line'>export LSCOLORS=DxGxcxdxCxegedabagacad
</span><span class='line'>
</span><span class='line'>
</span><span class='line'>#############################################
</span><span class='line'># alias
</span><span class='line'>#############################################
</span><span class='line'>
</span><span class='line'>alias ll='ls -l'
</span><span class='line'>alias la='ls -la'
</span><span class='line'>
</span><span class='line'>########
</span><span class='line'>## git
</span><span class='line'>
</span><span class='line'>alias g='git status'
</span><span class='line'>alias gg='git log'
</span><span class='line'>alias gst='git status'
</span><span class='line'>
</span><span class='line'>alias gb='git branch'
</span><span class='line'>alias gba='git branch -a'
</span><span class='line'>
</span><span class='line'>alias gc='git commit -v'
</span><span class='line'>alias gca='git commit -v -a'
</span><span class='line'>alias gce="git commit --amend" # fix last commit message
</span><span class='line'>alias gco='git checkout'
</span><span class='line'>
</span><span class='line'>alias gd='git diff | bbedit'
</span><span class='line'>alias gdm='git diff master'
</span><span class='line'>
</span><span class='line'>alias gl='git pull'
</span><span class='line'>alias gp='git push'
</span><span class='line'>
</span><span class='line'>
</span><span class='line'>#############################################
</span><span class='line'># update path for mysql and pear
</span><span class='line'>#############################################
</span><span class='line'>
</span><span class='line'>export PATH=/usr/local/mysql/bin:/usr/local/share/npm/bin:$PATH
</span><span class='line'>
</span><span class='line'>#############################################
</span><span class='line'># RVM - for managing versions of ruby
</span><span class='line'>#############################################
</span><span class='line'>
</span><span class='line'>[[ -s "~/.rvm/scripts/rvm" ]] && source "~/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
</span><span class='line'>
</span><span class='line'>
</span><span class='line'>ENDOFMESSAGE
</span><span class='line'>
</span><span class='line'># prevent gems from installing docs
</span><span class='line'>echo 'gem: --no-rdoc --no-ri' >> ~/.gemrc
</span><span class='line'>
</span><span class='line'># install gems
</span><span class='line'>gem install bundler
</span><span class='line'>gem install mysql2
</span><span class='line'>
</span><span class='line'>#### if you have issues with mysql2
</span><span class='line'>#### ** mysql 5.6.12
</span><span class='line'># change the mysql_config file
</span><span class='line'># then try installing again
</span><span class='line'># http://stackoverflow.com/questions/5919727/bundle-install-problem-mysql-h-is-missing
</span><span class='line'># http://www.randomactsofsentience.com/2013/05/gem-install-mysql2-missing-mysqlh-on-os.html
</span><span class='line'>vi /usr/local/Cellar/mysql/5.6.12/bin/mysql_config</span></code></pre></td></tr></table></div></figure>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[RAILS: Eager Loading in activerecord ignores select method]]></title>
<link href="http://bluengreen.github.io/blog/2013/09/21/rails-eager-loading-in-activerecord-ignores-select-method/"/>
<updated>2013-09-21T03:25:00-05:00</updated>
<id>http://bluengreen.github.io/blog/2013/09/21/rails-eager-loading-in-activerecord-ignores-select-method</id>
<content type="html"><![CDATA[<p>If your trying to use the select method in Activercord, and you are finding that your select does not work, your issue may be with eager loading. It turns out that when you eager load with the includes method, the select method is completely ignored.</p>
<!-- more -->
<h2>This does not work</h2>
<figure class='code'><figcaption><span>example_controller.rb </span></figcaption>
<div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
</pre></td><td class='code'><pre><code class='rb'><span class='line'> <span class="vi">@posts</span> <span class="o">=</span> <span class="no">Post</span><span class="o">.</span><span class="n">select</span><span class="p">(</span><span class="s1">'title, categories.name AS category_name'</span><span class="p">)</span>
</span><span class='line'> <span class="o">.</span><span class="n">joins</span><span class="p">(</span><span class="ss">:category</span><span class="p">)</span>
</span><span class='line'> <span class="o">.</span><span class="n">includes</span><span class="p">(</span><span class="ss">:category</span><span class="p">)</span>
</span><span class='line'> <span class="o">.</span><span class="n">where</span><span class="p">(</span><span class="s2">"categories.name='News'"</span><span class="p">)</span>
</span><span class='line'> <span class="vi">@grouped_posts</span> <span class="o">=</span> <span class="vi">@posts</span><span class="o">.</span><span class="n">group_by</span><span class="p">(</span><span class="ss">:category_name</span><span class="p">)</span>
</span></code></pre></td></tr></table></div></figure>
<h2>Solution</h2>
<p>Remove the includes.</p>
<figure class='code'><figcaption><span>example_controller.rb </span></figcaption>
<div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
</pre></td><td class='code'><pre><code class='rb'><span class='line'> <span class="vi">@posts</span> <span class="o">=</span> <span class="no">Post</span><span class="o">.</span><span class="n">select</span><span class="p">(</span><span class="s1">'title, categories.name'</span><span class="p">)</span>
</span><span class='line'> <span class="o">.</span><span class="n">joins</span><span class="p">(</span><span class="ss">:category</span><span class="p">)</span>
</span><span class='line'> <span class="o">.</span><span class="n">where</span><span class="p">(</span><span class="s2">"categories.name='News'"</span><span class="p">)</span>
</span><span class='line'> <span class="vi">@grouped_posts</span> <span class="o">=</span> <span class="vi">@posts</span><span class="o">.</span><span class="n">group_by</span><span class="p">(</span><span class="ss">:category_name</span><span class="p">)</span>
</span></code></pre></td></tr></table></div></figure>
<h2>Beware</h2>
<p>Beware that this can also happen when using gems that use eager loading. Making it harder to notice that is the issue.</p>
<p>Hope this saves you some time.</p>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[Linux CheatSheet]]></title>
<link href="http://bluengreen.github.io/blog/2013/09/21/linux-cheatsheet/"/>
<updated>2013-09-21T01:26:00-05:00</updated>
<id>http://bluengreen.github.io/blog/2013/09/21/linux-cheatsheet</id>
<content type="html"><![CDATA[<p>Helpful reminders to linux commands</p>
<!-- more -->
<h2>Tar/gzip</h2>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>tar -czvf archive.tgz directory_to_archive</span></code></pre></td></tr></table></div></figure>
<h2>Find stuff</h2>
<p>Find files older than 3 days old and remove them.</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>find . -mtime +3 | xargs rm -Rf</span></code></pre></td></tr></table></div></figure>
<h2>Move stuff</h2>
<p>Move files that start with any character between a and m into a directory called dir</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>mv [a-m]* dir</span></code></pre></td></tr></table></div></figure>
<h2>List stuff</h2>
<p>List number of files in the current working directory.</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>ll | wc -l</span></code></pre></td></tr></table></div></figure>
<h2>Transfer stuff</h2>
<p>Copy local file to remote server.</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>scp filename.txt [email protected]:/path/to/my/remote/dir/filename.txt </span></code></pre></td></tr></table></div></figure>
<p>Copy remote file to local file system.</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>scp [email protected]:/path/to/my/remote/dir/filename.txt ../local/filename.txt </span></code></pre></td></tr></table></div></figure>
<h2>sysadmin</h2>
<p>Look for a process with the keyword mysql</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>ps -ef | grep mysql </span></code></pre></td></tr></table></div></figure>
<p>List iptable rules</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>iptables -L </span></code></pre></td></tr></table></div></figure>
]]></content>
</entry>
</feed>