Thursday, November 24, 2016

Trigger on Marksman 1790 "Biathlon" air rifle

I've had one of these lying around for years. Picked it back up recently and the trigger was horrible, almost unusable. So I took it apart of course. There's a single pin that holds the two halves together and drifts out with a 3/16" punch:

This also allows the action to be removed from the stock. Here's a picture of the "roller" sear with an arrow showing the point of contact:


Note the main spring is removed here to show what it would look like cocked. Also, I recommend disassembling with the right side down, opposite of how it is shown here. That requires removing the four screws and then flipping the action over before removing the left side up and off.
My roller was no longer rolling at all; some WD-40 solved that problem. I also cleaned up the face of the lower silver part with 220 and 500 grit sandpaper. It appeared the face had been dinged by the roller not rolling. Here's a shot with the trigger spring in its proper place, mine went flying upon disassembly and it took some time to figure out how it goes back. I recommend reassembly on the right side, again opposite of what is shown here, as it makes things a little easier.

I emailed info at marksman dot com to no avail to ask about this, so I hope this proves useful to someone out there. The trigger is so much better now.

Saturday, September 17, 2016

RT-N66U interface failure and nvram

I upgraded an ASUS RT-N66U router, and it broke the user interface. The router has been a very good one, very reliable until now. Does anyone wonder why we all hate upgrading? Okay. Deep calming breath. I can no longer set the DNS server address in the DHCP tab; I can ssh to the router, and so set the DHCP DNS server value that way. Looks like
nvram set dhcp_dns1_x=192.168.19.1
There's a lesson in here somewhere.

Monday, August 22, 2016

More than you wanted to know about Laravel and M2M

One approach is to create a scaffold for the M2M table and enter the mappings there. I did:

php artisan make:scaffold --schema=name:string person
php artisan make:scaffold --schema=todo:string todo
php artisan make:scaffold --schema='todo_id:integer:foreign,person_id:integer:foreign' PeopleTodo

Then, I had to make some changes with the each of the MVC. Maybe I'll get around to post about using Form:: and  an example where the pivot doesn't have a scaffold but where each class has and add/delete drop down. In any care, here are the raw diffs.

diff --git a/app/Http/Controllers/PeopleTodoController.php b/app/Http/Controllers/PeopleTodoController.php
index f34e019..dafb9fa 100644
--- a/app/Http/Controllers/PeopleTodoController.php
+++ b/app/Http/Controllers/PeopleTodoController.php
@@ -1,5 +1,7 @@
 <?php namespace App\Http\Controllers;
 
+use App\Person;
+use App\Todo;
 use App\Http\Requests;
 use App\Http\Controllers\Controller;
 
@@ -15,9 +17,11 @@ class PeopleTodoController extends Controller {
      */
     public function index()
     {
+        $people = Person::all();
+        $todos = Todo::all();
         $people_todos = PeopleTodo::orderBy('id', 'desc')->paginate(10);
 
-        return view('people_todos.index', compact('people_todos'));
+        return view('people_todos.index', compact('people_todos', 'people', 'todos'));
     }
 
     /**
@@ -27,7 +31,9 @@ class PeopleTodoController extends Controller {
      */
     public function create()
     {
-        return view('people_todos.create');
+        $people = Person::all();
+        $todos = Todo::all();
+        return view('people_todos.create', compact( 'people', 'todos'));
     }
 
     /**
@@ -40,10 +46,8 @@ class PeopleTodoController extends Controller {
     {
         $people_todo = new PeopleTodo();
 
-        $people_todo->todo_id = $request->input("todo_id");
-        $people_todo->todo_id = $request->input("todo_id");
-        $people_todo->person_id = $request->input("person_id");
         $people_todo->person_id = $request->input("person_id");
+        $people_todo->todo_id = $request->input("todo_id");
 
         $people_todo->save();
 
@@ -59,8 +63,10 @@ class PeopleTodoController extends Controller {
     public function show($id)
     {
         $people_todo = PeopleTodo::findOrFail($id);
+        $person = Person::findOrFail($people_todo->person_id)->name;
+        $todo = Todo::findOrFail($people_todo->todo_id)->todo;
 
-        return view('people_todos.show', compact('people_todo'));
+        return view('people_todos.show', compact('people_todo', 'person', 'todo'));
     }
 
     /**
@@ -71,9 +77,12 @@ class PeopleTodoController extends Controller {
      */
     public function edit($id)
     {
+        $people = Person::all();
+        $todos = Todo::all();
         $people_todo = PeopleTodo::findOrFail($id);
 
-        return view('people_todos.edit', compact('people_todo'));
+        return view('people_todos.edit', compact('people_todo', 'people',
+            'todos'));
     }
 
     /**
@@ -88,8 +97,6 @@ class PeopleTodoController extends Controller {
         $people_todo = PeopleTodo::findOrFail($id);
 
         $people_todo->todo_id = $request->input("todo_id");
-        $people_todo->todo_id = $request->input("todo_id");
-        $people_todo->person_id = $request->input("person_id");
         $people_todo->person_id = $request->input("person_id");
 
         $people_todo->save();
diff --git a/app/Http/Controllers/PersonController.php b/app/Http/Controllers/PersonController.php
index 7acbf6b..a7809d9 100644
--- a/app/Http/Controllers/PersonController.php
+++ b/app/Http/Controllers/PersonController.php
@@ -1,5 +1,6 @@
 <?php namespace App\Http\Controllers;
 
+use App\Todo;
 use App\Http\Requests;
 use App\Http\Controllers\Controller;
 
diff --git a/app/PeopleTodo.php b/app/PeopleTodo.php
index d2f1afb..03c1db4 100644
--- a/app/PeopleTodo.php
+++ b/app/PeopleTodo.php
@@ -6,5 +6,4 @@ use Illuminate\Database\Eloquent\Model;
 
 class PeopleTodo extends Model
 {
-    //
 }
diff --git a/app/Person.php b/app/Person.php
index ebc7dea..f6be618 100644
--- a/app/Person.php
+++ b/app/Person.php
@@ -6,5 +6,8 @@ use Illuminate\Database\Eloquent\Model;
 
 class Person extends Model
 {
-    //
+    public function todos()
+    {
+        return $this->belongsToMany('App\Todo', 'people_todos');
+    }
 }
diff --git a/app/Todo.php b/app/Todo.php
index e21e027..28febf5 100644
--- a/app/Todo.php
+++ b/app/Todo.php
@@ -6,5 +6,8 @@ use Illuminate\Database\Eloquent\Model;
 
 class Todo extends Model
 {
-    //
+    public function people()
+    {
+        return $this->belongsToMany('App\Person', 'people_todos');
+    }
 }
diff --git a/resources/views/people/show.blade.php b/resources/views/people/show.blade.php
index 7534417..f5edabe 100644
--- a/resources/views/people/show.blade.php
+++ b/resources/views/people/show.blade.php
@@ -19,13 +19,14 @@
 
             <form action="#">
                 <div class="form-group">
-                    <label for="nome">ID</label>
-                    <p class="form-control-static"></p>
-                </div>
-                <div class="form-group">
                      <label for="name">NAME</label>
                      <p class="form-control-static">{{$person->name}}</p>
                 </div>
+                 <label>TODOS</label>
+                <ul>
+                    <? foreach ($person->todos as $todo)
+                        { echo ('<li>'.$todo->todo.'</li>'); } ?>
+                </ul>
             </form>
 
             <a class="btn btn-link" href="{{ route('people.index') }}"><i class="glyphicon glyphicon-backward"></i>  Back</a>
diff --git a/resources/views/people_todos/create.blade.php b/resources/views/people_todos/create.blade.php
index eadd702..335ad2a 100644
--- a/resources/views/people_todos/create.blade.php
+++ b/resources/views/people_todos/create.blade.php
@@ -18,29 +18,38 @@
                 <input type="hidden" name="_token" value="{{ csrf_token() }}">
 
                 <div class="form-group @if($errors->has('todo_id')) has-error @endif">
-                       <label for="todo_id-field">Todo_id</label>
-                    <input type="text" id="todo_id-field" name="todo_id" class="form-control" value="{{ old("todo_id") }}"/>
-                       @if($errors->has("todo_id"))
-                        <span class="help-block">{{ $errors->first("todo_id") }}</span>
-                       @endif
-                    </div>
-                    <div class="form-group @if($errors->has('todo_id')) has-error @endif">
-                       <label for="todo_id-field">Todo_id</label>
-                    <input type="text" id="todo_id-field" name="todo_id" class="form-control" value="{{ old("todo_id") }}"/>
+
+                    <select
+                        id="todo_id-field"
+                        name="todo_id"
+                        class="form-control">
+                        <?php foreach ($todos as $todo) { ?>
+                            <option value="<?php echo $todo->id; ?>">
+                                <?php echo $todo->todo; ?>
+                            </option>
+                        <?php } ?>
+                    </select>
+
                    @if($errors->has("todo_id"))
-                        <span class="help-block">{{ $errors->first("todo_id") }}</span>
-                       @endif
-                    </div>
-                    <div class="form-group @if($errors->has('person_id')) has-error @endif">
-                       <label for="person_id-field">Person_id</label>
-                    <input type="text" id="person_id-field" name="person_id" class="form-control" value="{{ old("person_id") }}"/>
-                       @if($errors->has("person_id"))
-                        <span class="help-block">{{ $errors->first("person_id") }}</span>
+                   <span class="help-block">{{ $errors->first("todo_id")
+}}</span>
                    @endif
                     </div>
+
                     <div class="form-group @if($errors->has('person_id')) has-error @endif">
-                       <label for="person_id-field">Person_id</label>
-                    <input type="text" id="person_id-field" name="person_id" class="form-control" value="{{ old("person_id") }}"/>
+                    <label for="person_id-field">Person</label>
+
+                    <select
+                        id="person_id-field"
+                        name="person_id"
+                        class="form-control">
+                        <?php foreach ($people as $person) { ?>
+                            <option value="<?php echo $person->id; ?>">
+                                <?php echo $person->name; ?>
+                            </option>
+                        <?php } ?>
+                    </select>
+
                     @if($errors->has("person_id"))
                     <span class="help-block">{{ $errors->first("person_id") }}</span>
                     @endif
diff --git a/resources/views/people_todos/edit.blade.php b/resources/views/people_todos/edit.blade.php
index 6ef2168..dfcdb0c 100644
--- a/resources/views/people_todos/edit.blade.php
+++ b/resources/views/people_todos/edit.blade.php
@@ -19,29 +19,37 @@
                 <input type="hidden" name="_token" value="{{ csrf_token() }}">
 
                     <div class="form-group @if($errors->has('todo_id')) has-error @endif">
-                       <label for="todo_id-field">Todo_id</label>
-                    <input type="text" id="todo_id-field" name="todo_id" class="form-control" value="{{ is_null(old("todo_id")) ? $people_todo->todo_id : old("todo_id") }}"/>
-                       @if($errors->has("todo_id"))
-                        <span class="help-block">{{ $errors->first("todo_id") }}</span>
-                       @endif
-                    </div>
-                    <div class="form-group @if($errors->has('todo_id')) has-error @endif">
-                       <label for="todo_id-field">Todo_id</label>
-                    <input type="text" id="todo_id-field" name="todo_id" class="form-control" value="{{ is_null(old("todo_id")) ? $people_todo->todo_id : old("todo_id") }}"/>
+                    <label for="todo_id-field">Todo</label>
+
+                    <select
+                        id="todo_id-field"
+                        name="todo_id"
+                        class="form-control">
+                        <?php foreach ($todos as $todo) { ?>
+                            <option value="<?php echo $todo->id; ?>">
+                                <?php echo $todo->todo; ?>
+                            </option>
+                        <?php } ?>
+                    </select>
+
                    @if($errors->has("todo_id"))
                    <span class="help-block">{{ $errors->first("todo_id") }}</span>
                    @endif
                     </div>
+
                     <div class="form-group @if($errors->has('person_id')) has-error @endif">
-                       <label for="person_id-field">Person_id</label>
-                    <input type="text" id="person_id-field" name="person_id" class="form-control" value="{{ is_null(old("person_id")) ? $people_todo->person_id : old("person_id") }}"/>
-                       @if($errors->has("person_id"))
-                        <span class="help-block">{{ $errors->first("person_id") }}</span>
-                       @endif
-                    </div>
-                    <div class="form-group @if($errors->has('person_id')) has-error @endif">
-                       <label for="person_id-field">Person_id</label>
-                    <input type="text" id="person_id-field" name="person_id" class="form-control" value="{{ is_null(old("person_id")) ? $people_todo->person_id : old("person_id") }}"/>
+                    <label for="person_id-field">Person</label>
+
+                    <select
+                        id="person_id-field"
+                        name="person_id"
+                        class="form-control">
+                        <?php foreach ($people as $person) { ?>
+                            <option value="<?php echo $person->id; ?>">
+                                <?php echo $person->name; ?>
+                            </option>
+                        <?php } ?>
+                    </select>
                     @if($errors->has("person_id"))
                     <span class="help-block">{{ $errors->first("person_id") }}</span>
                     @endif
diff --git a/resources/views/people_todos/index.blade.php b/resources/views/people_todos/index.blade.php
index a7ce276..43d51a8 100644
--- a/resources/views/people_todos/index.blade.php
+++ b/resources/views/people_todos/index.blade.php
@@ -17,11 +17,8 @@
                 <table class="table table-condensed table-striped">
                     <thead>
                         <tr>
-                            <th>ID</th>
-                            <th>TODO_ID</th>
-                        <th>TODO_ID</th>
-                        <th>PERSON_ID</th>
-                        <th>PERSON_ID</th>
+                        <th>TODO</th>
+                        <th>PERSON</th>
                             <th class="text-right">OPTIONS</th>
                         </tr>
                     </thead>
@@ -29,11 +26,8 @@
                     <tbody>
                         @foreach($people_todos as $people_todo)
                             <tr>
-                                <td>{{$people_todo->id}}</td>
-                                <td>{{$people_todo->todo_id}}</td>
-                    <td>{{$people_todo->todo_id}}</td>
-                    <td>{{$people_todo->person_id}}</td>
-                    <td>{{$people_todo->person_id}}</td>
+                                <td>{{$todos->find($people_todo->todo_id)->todo}}</td>
+                                <td>{{$people->find($people_todo->person_id)->name}}</td>
                                 <td class="text-right">
                                     <a class="btn btn-xs btn-primary" href="{{ route('people_todos.show', $people_todo->id) }}"><i class="glyphicon glyphicon-eye-open"></i> View</a>
                                     <a class="btn btn-xs btn-warning" href="{{ route('people_todos.edit', $people_todo->id) }}"><i class="glyphicon glyphicon-edit"></i> Edit</a>
diff --git a/resources/views/people_todos/show.blade.php b/resources/views/people_todos/show.blade.php
index b3e6087..923ed04 100644
--- a/resources/views/people_todos/show.blade.php
+++ b/resources/views/people_todos/show.blade.php
@@ -19,24 +19,12 @@
 
             <form action="#">
                 <div class="form-group">
-                    <label for="nome">ID</label>
-                    <p class="form-control-static"></p>
+                     <label for="person_id">PERSON</label>
+                     <p class="form-control-static">{{$person}}</p>
                 </div>
                 <div class="form-group">
-                     <label for="todo_id">TODO_ID</label>
-                     <p class="form-control-static">{{$people_todo->todo_id}}</p>
-                </div>
-                    <div class="form-group">
-                     <label for="todo_id">TODO_ID</label>
-                     <p class="form-control-static">{{$people_todo->todo_id}}</p>
-                </div>
-                    <div class="form-group">
-                     <label for="person_id">PERSON_ID</label>
-                     <p class="form-control-static">{{$people_todo->person_id}}</p>
-                </div>
-                    <div class="form-group">
-                     <label for="person_id">PERSON_ID</label>
-                     <p class="form-control-static">{{$people_todo->person_id}}</p>
+                     <label for="todo_id">TODO</label>
+                     <p class="form-control-static">{{$todo}}</p>
                 </div>
             </form>
 


Thursday, August 11, 2016

Debian 8 and gnome 3 notes

https://extensions.gnome.org/extension/120/system-monitor/

gsettings set org.gnome.desktop.wm.preferences button-layout ":minimize,maximize,close"
Tweaktool can at least turn them on.

Tuesday, July 12, 2016

Cygwin and Laravel

I played with getting cygwin to run Laravel and the l5scaffold. Here are the additions you need to install in cygwin
  1. php, git, sqlite3, and curl.
  2. The following php extensions.
    1. json
    2. phar
    3. mbstring
    4. zip
    5. tokenizer
    6. pdo-sqlite
    7. ctype
Don't if anyone else will ever, need this, but there ya go.

Sunday, May 29, 2016

Photo panoramas

I've used and liked Hugin before and blogger about it here. I recently downloaded the latest version and I just couldn't figure out how to use it. My bad no doubt, but after an hour getting no traction using the user's guide, I gave up and looked for something else. autostitch was the answer. Three clicks and I was done.

Thursday, March 24, 2016

Audacity create labels

Geez I like Audacity. I recently needed to put track markers in a long "song" and it's built right in. Choose Analyze -> Regular Interval Tracks. I like ten minutes and the number after the "Label":

Wednesday, January 27, 2016

How to become a security professional

Well, really, here are some useful links.

http://www.darkreading.com/careers-and-people/why-cybersecurity-certifications-matter----or-not/d/d-id/1324004?_mc=RSS_DR_EDT
http://www.zdnet.com/article/getting-started-with-a-career-in-cybersecurity/
http://www.troyhunt.com/2015/09/troys-ultimate-list-of-security-links.html
https://www.cybrary.it/course/advanced-penetration-testing/

Friday, January 15, 2016

Rockbox Rocks

I wanted to put a bunch of music on a Sansa Clip+ or Sport Clip and both seriously messed up the order of the tracks. First, ID3 v1 doesn't support more than 255 tracks, which wasn't enough. I used mutagen (https://bitbucket.org/lazka/mutagen) to make sure the tracks were numbered correctly via this script
TOTAL=`ls -1 | wc -l | sed -e "s/ //g"`
COUNT=1

for i in *
do
    mid3v2 -T "$COUNT/$TOTAL" "$i"
    mid3v2 --delete-v1 "$i"
    COUNT=$((COUNT+1))
done
The downside with mutagen is that it always converts to ID3 v2.4 that many players won't recognize. Nicely, with mp3tag (http://www.mp3tag.de/en/) one can choose the version desired, and there is an automated track numbering tool. Still no joy. As best as I can tell, the Sansa clips have a bug or two that make the whole effort futile. Enter Rockbox (http://www.rockbox.org/). I had no idea there was such a thing as free music player firmware. Cool! I downloaded the installer and the necessary Sansa firmware from http://forums.sandisk.com/t5/Sansa-Clip-Sansa-Clip/Sansa-Clip-Firmware-Update-01-02-16/td-p/150227, ran the installer, and it worked! So I did what I always do: donated to the mp3tag and Rockbox projects. The Clip Sport is not currently supported by Rockbox...
I learned far more about mp3 tagging than I ever wanted to, so thought I'd pass a little of the learning on.