Tuesday, April 13, 2021

Fix: Cannot use gmail and google drive on Safari

With the newer versions of ios, such as ios 13, you can customize your Safari features. While browsing the Experimental Webkit Features, I accidentally enabled requestIdleCallback, which made it impossible to login to any google accounts.

To disable requestIdleCallback on your device and re-gain access to your google accounts, do the following. First, go to the Settings app. Then choose the following series of options: Safari > Advanced > Experimental Features. Finally, disable requestIdleCallback.

Monday, February 11, 2019

GetContents() of Previous Version of Document in DFC

Documentum provides the Documentum Foundation Classes(DFC) as a Java library to connect to Documentum. When dealing with documents, it may be necessary to get prior versions, instead of the current version. But the sessionManager methods like getObjectByQualification seem to only work on the current r_object_id or current version of that document. Searching by r_object_id returns null or throws an exception.

In order to get older versions of the document, you must add ALL when you do getObjectByQualification(). Then you can get the prior or previous document or file without having to delete or destroy the latest one in any way. Below is a code example.
import java.io.*; 
import com.documentum.fc.client.IDfSession;
import com.documentum.fc.client.IDfSessionManager;
import com.documentum.fc.client.IDfSysObject;

public class OlderVersions {

   public static String getOlderVersion(            
       String repositoryName,            
       IDfSessionManager sessionManager,            
       String documentName)     
   {
        IDfSession mySession = null;
        try {            
            mySession = sessionManager.getSession(repositoryName);
            // search for the object using the filename             
            IDfSysObject existingDoc = (IDfSysObject) mySession.getObjectByQualification(                 
                "dm_document (ALL) where object_name='" + documentName + "'"
            );
            if (existingDoc != null) {
            //object with that filename exists
                //then extract the contents of the file
                ByteArrayInputStream dumpedCorrection = existingDoc.getContent();
            } else {
                System.out.println("no file found for " + documentName);
            }
        } catch (Exception ex) {
                ex.printStackTrace();
        } finally {
            //  release the session
            sessionManager.release(mySession);
        }
    }
}

A similar thing can be done to find repeating attributes such as r_version_label. But in that case, the keyword is ANY:

IDfSysObject existingDoc = 
    (IDfSysObject) mySession.getObjectByQualification(                 
        "dm_document where object_name='" + documentName + 
        " and any r_version_label='THE_LABEL_NAME_YOU_USE''"
    );

The above can also be done directly in a DQL query. But this post is for people who don't know how to use DQL or who want to build on what they learned in the DFC Development Guide.

Thursday, June 21, 2018

How to Use Git Collaboratively


For those who already have experience with git the next step tends to be contributing to a code base multiple people are working on. There are two ways to contribute, have access to the repository or fork the repository and do a pull request with the commits you want included in the main repository.
Replace everything in red with your respective names
$ git clone https://github.com/github-group/repo-name.git

Gaining access to the repository

If the repo is in a group then you need group access from the group administrator then you need write permissions for the repository from the repository owner to start committing to it. Then you need to set your git remote origin to point to that specific repository

Pull requests

Pull requests are a useful way to share code of an existing repository you don’t have access to or from a branch that needs to be merged into the master branch

Adding features

When working on a code repository it’s important to do all new features on feature branches, preferably with the branch named after the feature being implemented.

$ git checkout -b branchname
$ git push origin branchname
When you want to switch to an existing branch:
$ git checkout branchname
But it’s also important to keep the branch updated with any changes on the master. The rebasing option puts all your recent commits on top of the pulled commits.
$ git stash
$ git checkout branchname
$ git pull --rebase origin master
$ git push
$ git stash pop

Commiting

In order to save your work you need to commit it. But make sure you only save the specific changes you want in your commit and nothing else. To do that it’s important to do git diff to verify everything that you’re staging and committing. It’s also a good practice to have only one small feature per commit so it is easy to track via the commit log, what changes have been made. It’s better to have several small functional commits than one large commit. However, if you would like to save WIP code then it’s important to do them on a separate branch then rebase or perform a pull request which will squash them all into one commit.

Undoing a commit

For a local commit you undo it by
$ git reset HEAD~
Then you’ll need to add them and commit them again.
For a remote commit
$ git revert commitnumber

Saving local changes without committing

Sometimes you have something that’s a WIP progress that you would like to keep but don’t feel ready to commit yet. However, you need to pull the changes from the remote code repository. That’s when you use git stash. It saves your local changes for you to regain later.
$ git stash
$ git pull
$ git stash pop
Occasionally there will be conflicts during a git stash pop which you then need to resolve in each file. They’ll show up as something like the following:
<<<<HEAD
======
>>> LOCAL CHANGES
You’ll need to keep the changes that work best for you and delete the rest.
 

Then, it’s important to either merge the changes back to remote


$ git push

OR do a git reset so that the resolution between the pull and the stash are not staged.


$ git reset HEAD~

Merging a feature branch into master

When a feature is fully developed and tested, it could be useful to everyone. Then it’s a good idea to merge it back into master.

If you have access to the official repository then do the following:

$ git checkout master
$ git pull origin master
$ git merge branchname
$ git push origin master

Otherwise do a pull request

Possible git workflow

$ git diff
$ git stash
$ git pull
$ git stash apply/pop
$ git diff
$ git add filename
$ git commit -m commitmessage
$ git push
$ git status
 

Tuesday, December 26, 2017

Basic Overview of Machine Learning in Speech Recognition

These days speech recognition is usually performed with different varieties of machine learning algorithms.

First, the algorithms are translated into models. Then the models are used to recognize aligned audio data which is then considered a fully functional speech recognizer for most text in that language. 
Finally, free form audio is inputted and out comes a transcription of what was previously only audio signals.

Friday, October 6, 2017

Useful bookmarklets made by other people

These bookmarklets were made by other people and I found them really useful but I no longer remember where I got them so if you know who made them please contact me and I'll add in the credits.

In browser text editor (useful for notes and making bookmarklets on the fly):\

javascript:(function(){window.open('data:text/html;charset=utf-8,<title>TextEditor</title><style>html{height: 100%;}body{margin:0;padding:4%;border:20px solid #eee;background-color:#fff;border-radius:2em}textarea{width:100%;height:100%;border:0 none;font-family:"Lucida Grande",sans-serif;font-size:2em;outline:none;color:#444}</style><body><textarea spellcheck="false" autofocus="autofocus"></textarea></body></html>', '_blank');})();

Estimated time to read:
javascript:(function(){function getTextNodesIn(c){var d=0,b=/^\s*$/;function a(g){if(g.nodeType==3){if(!b.test(g.nodeValue)){d+=g.nodeValue.split(" ").length}}else{for(var f=0,e=g.childNodes.length;f<e;++f){a(g.childNodes[f])}}}a(c);return d}alert("Estimated reading time: "+(getTextNodesIn(document.body)/250)+" minutes")}());

A bookmarklet version which allows local storage so no worries about closing it but Chrome currently considers it malicious: http://blog.getsetbro.com/Bookmarklet-to-make-your-browser-a-Text-Editor.html 

Saturday, June 17, 2017

Enabling the Windows Printer via Samba option after installing CUPS

Let’s say you have CUPS installed and now you want access to a Windows Printer on the network but it can only be accessed via SAMBA (SMB). However, on your CUPS Add Printer options you can’t find one to add a SAMBA printer.

In order to enable it, you need to open a terminal and run the following commands:

sudo apt install samba
sudo apt-get install libsmbclient
sudo apt-get install smbclient
sudo apt-get install python-smbc
sudo service cups restart

Then, Windows Printer via SAMBA should show up as one of your last options in Add Printer.

If the printer can only be accessed via login then you will have to add the credentials as part of the URI like this:
smb://username:password@domainname/printserver/V_2_24

Warning! If your username or password has reserved characters: ! * ' ( ) ; : @ & = + $ , / ? % # [ ] then you'll need to percent escape them to represent them correctly, especially for @; the URL will get confused with the @ used before the domain name.

Otherwise, the job will be held up in the queue and print jobs will return an internal error like this: Session setup failed: NT_STATUS_INTERNAL_ERROR

Happy Printing!

Resources:

Sunday, April 30, 2017

Dualbooting Debian and Windows when you have already installed Debian.

When dualbooting Linux and Windows, it is often recommended to install Windows first because of the various difficulties of doing it in reverse (e.g. GRUB breaking). However sometimes you want to keep Linux on your computer. So let's start this guide.

Hardware you will need:
Computer with a hard drive big enough and enough free space to fit (Windows 10 and Debian)
3 flash drives at least one must be 6GBs
Extra external hard drive

Main software necessary:
Copy of Windows 10 (product key too if necessary)
Copy of Debian (on your computer)

1. You start with a computer installed with Debian. Preferably, the boot and home directories will be in separate partitions. Make sure to backup all your important data to your external flash drive.

2. Then you need to install GParted on the first flash drive.

3. With GParted on the flash drive, you stick the flash drive into your laptop then load up the Grub bootloader to load the USB instead from the hard drive.
a. Then, since you're not running GParted from the home partition, you can load up GParted and resize your hard drive so you have unallocated space. Usually the home partition is the largest partition so you would shrink that if you have space. I'd estimate at least about 100GB free space for each OS if you're planning on keeping any data or installing any applications. After GParted is done then you can shut down the computer and pull out your GParted flash drive.

4. Install Windows on your second flash drive. Since debian will most likely not be installed using UEFI, on the flash drive you must use the msdos format with a partition which has the boot flag. If the flash drive won't mount after reformatting it, then manually mount it yourself in a convenient location like /home/USERNAME/Documents/WindowsMount where USERNAME should be replaced with your own username on Debian. Assuming your Windows was downloaded as a disk image, either mount the image or right click and extract all the contents of the ISO to the flash drive. Windows is about 4Gbs so use your larger flash drive. After you have installed Windows on your flash drive, you must turn off the computer and turn it back on. When it gets to the manufacturer logo screen like ASUS or Dell, then you must immediately press the key for your BIOS menu. It is manufacturer dependent so you'll have to look up MANUFACTURER BIOS menu key and from there you have to choose to load from your usb. Once you've saved the settings, you turn off your computer again and it should load directly from your Windows USB.

5. Once you've gone through all the Windows settings (and most importantly turning off automatic updates), then you need to download Rufus and Boot Repair then on your third flash drive you use Rufus to install Boot Repair on your flash drive. Make sure to label your flash drive. After you've done that you also need to make a grub.cfg file (it's basically to install grub on your flash drive) on your flash drive which references your flash drive by the label you gave it. So then you need to turn off your computer and then boot it and on the DELL screen you need to press your BIOS menu key again and once again tell your computer to load from a USB flash instead. This time the label should be clearly visible as your selection. Then you load up the Boot Repair OS and select repair disk and it'll restore your Grub loader so that the next time you turn on your computer you'll see both your Debian installation (and the various recovery modes and whatnot) and an option to load Windows 10.

Congratulations you have successfully dualbooted Debian and Windows 10!

Negatives of React and Angular

Both React JS and Angular JS are great frameworks; however, they both focus on the one page app, which works with phone specific devices but it doesn't work as well with web apps which want to have multiple pages. Additional packages needed to be downloaded to make the frameworks work with multiple pages.

In React JS, the lingo used to make multiple pages is called routing. The two main ones recommended in the Meteor guide are kadira: flow-reactor and react-router. The first router is a Meteor specific one; the second one is a react specific one. Other ones are IronRouter and BackboneJS. But, BackboneJS is considered by some to be outdated now.

Routing is where you dictate where React routes traffic to your app. It is mostly done by mapping files with words used to reference those files. For example if you want to make error pages such as 500 or 404 then you can map those files/pages to the word, 'error' then specify where it goes depending on which kind of error it is.

Hopefully this article helps you properly prepare for the limitations when making web apps in React or Angular, especially in React since that was mentioned the most.

Saturday, April 8, 2017

MongoDB

MongoDB is a NoSQL database. It is pretty easy to use on the command line interface.

So far my favorite aspect of NoSQL is making collections (tables in SQL) and entries on the fly. It doesn't require a schema, although a schema still helps organize and validate Mongo databases. If you don't have a collection then it makes the collection for you to put in your new data entry. SQL is a lot harder to modify without massively disrupting existing tables and code.

I recommend you try MongoDB the next time you need a database.

Friday, July 1, 2016

How to Make a Facebook Bot on a Windows Machine

Recently Facebook launched its Facebook Messenger bot API. Since then there has been a surge of developers and jobs opening up for chatbots. Being a bit curious about how easy it is to make a chatbot, what with companies and small time developers already having bots for services such as IRC, I decided to dip my toes into the bot developer world.

Since then I have been following this messenger bot guide, Develop your first Facebook messenger bot in PHP by Adnan Siddiqi,  with a couple of google searches added in.

Previously your app was default connected to the various Facebook products. But now, after making a new basic app, you have to "+Add Product." Then you have to find the messenger product and you'll then get the Messenger Platform "Getting Started" message button.

For example he already has cURL on his machine, either because it's UNIX based or because he'd previously downloaded it for his Windows machine. Here's the link to download the cURL binary (a.k.a. exe file) if you also need it: https://curl.haxx.se/dlwiz/ User the download wizard. Note: You're likely going to need the x86 version unless you have IA-64 (Intel Architecture 64) then you'd use that version.

Later on, I had to learn how to manipulate my files using the windows command prompt to make .htaccess files since Windows doesn't let you make those files naturally. It involved the "ren" command which I'm guessing is short for rename with the current file name location and the new name.

Right now everything works but cURL in my XAMPP setup. But without cURL my messenger app can't send messages back in the proper format to the messenger API and therefore it is only a silently receiving non talking bot. :(

Friday, February 26, 2016

Shell Script If Then Else logic

I was recently learning some shell scripting, so of course I only wanted some commands to trigger if a condition was met.
I wrote

if [condition] then
     echo "work please if"
else
  echo "work please else"
fi

but I kept getting an error on Terminal saying there was something wrong with my else, some unexpected else encountered.
So of course the problem was that if and then were on the same line, causing the if statement to be interpreted as a one-liner instead of a multi-liner.

Solution:
if [condition]
then
  echo "work please if"
else
  echo "work please else"
fi

I hope this helps some of you out there!

Thursday, February 18, 2016

Review of Introduction to Secure Computation Article

I recently read an article about secure computation by a undergrad. It was a great introduction in many ways. It clearly outlined and described the idea behind secure computation, how it is developed, and a brief idea of how to implement it. Each graphic included was useful and greatly illustrated the encryptions mentioned in the text.
But above all of those positive qualities, the most outstanding trait of the article is its slow introduction and but gradually more in-depth explanation of each cryptography term, leaving the reader more knowledgeable at the end of the article while leaving links for the reader to peruse if one wants to learn more about cryptography.

Thursday, December 17, 2015

Steps to Working as a Pentester

1. Read and follow public information and web security information and news.

2. Be a script kiddy and learn how those scripts run in a safe environment.

3. Write lots of code with validation and preventative measures. i.e. form validation to prevent SQL injections

  1. SQL injections - prepared statements, mysqli_real_escape_string()
  2. Cross site scripting(XSS) - preventing injected scripts from running on websites i.e. choose to interpret user content as stuff like &lt; instead of <
  3. Cross Site Request Forgery (CSRF) - prevent using one time tokens in forms


4. Submit reports to the Common Vulnerabilities and Exposures system.

5. Try them on existing companies with bug bounty systems like Reginaldo Silva did. Remote code executions provide nice payouts but remember to strike the proper balance between ethics, moral, and common sense behavior. Also, try to be upfront about the vulnerabilities presented.

6. If it's at an in house company then make sure they already have a risk assessment and security features and protocols in place for if security is breached. This article mentions steps to take before undergoing a pentest: https://www.cybersecdefense.com/information-security-testing-continuum/

Wednesday, September 16, 2015

Wifi Ethernet and Network Connections Stop Working After Laptop Battery Dies or Ubuntu Update

The other day I accidentally let my Ubuntu computer die. I didn't think much of it until I turned on my laptop a few days later and couldn't connect to a single wifi network, despite "Enable Networking" being checked.

In fact, it said No Network Devices Available.

The internet had a lot of solutions. After determining that I did have my drivers but they weren't detected, I kept thinking I'd have to reinstall the drivers to get my system to detect them.

But I finally found a solution on askubuntu.com which works on any Network or wireless card. What you do is boot/load an earlier version of the kernel, before the wifi stopped working.   So, during startup, right after pressing the power button on your laptop, hold down the shift key until GRUB comes up. It'll give you an option to view Advanced Additional Settings for Ubuntu (If you don't get that option then just move onto the next step). Then, a list of Ubuntu kernels will come up. The default one to load is the top one. Instead select the next highest, which should also be a smaller number. Then, your computer should load as normal and your wifi should be back up and working.

Don't choose the recovery mode ones.

Happy Internetting!

Sunday, September 6, 2015

Saving Order of Pages on Tumblr

On tumblr, users can make pages and rearrange them by moving them around on the Edit Theme sidebar. However, after rearranging the pages to an order you like, tumblr's save button doesn't popup. So, you can trick it into popping up by going in and editing in an inconsequential line break into one of your pages. Then, the page order you had made, will also be saved.

Happy tumbling!

Friday, September 4, 2015

Android Studio Problems, Workarounds & Solutions


  1. resource error: 
    No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Inverse'.
    Solution: Make sure the compiled SDK and the build toolkit SDK are the same version. This can be found in the Gradle folder. It is the first build gradle file. In it can be found the SDK versions listed, make sure to have matching SDKs listed and to make sure the SDKs are actually downloaded to Android Studio.
  2. Android Emulator won't run because x86 doesn't work on your computer and there is no way to accelerate your ARM processor.
    Solution: After selecting a device on AVD Manager in the toolbar, make sure to select to Show downloadable System Images. Then make sure to download an armebi processor instead of one of the x86 ones.
  3. Android emulator screen is stuck on "android" screen.
    Solution:

Tuesday, July 21, 2015

MK127 Running Microbug Build

I recently woke up and decided to work on a robot I got a while ago. It's a Velleman mini kit, the MK 127 Running Microbug. 

I looked online for the instructions in case it's a little more detailed than the picture ones within the kit. It had an electrical diagram but otherwise both sets of instructions are the same. Also, on the website itself, it tells you that you can test the motors with the ends of the battery holder and some batteries to find out if the motors themselves work. What it didn't mention which parts do the holder wires touch. It's the two metal areas where you thread through the jumper cables which are later soldered onto the board. 

The resistors are ready to be soldered.



Since I had soldered before and I knew the kit needed soldering, I was pretty good until it came time to solder the diode. The instructions didn't say anything about which side it should be soldered on but the board had a drawing that was pretty similar to how the the diode itself it looked. So I just went with it and soldered on the diode with the plastic cover. 

Note: My resistor trimmer/potentiometer was square unlike most of the videos online. If you twist the knob in the potentiometer, you can control how much resistant goes into the circuit from that point and thus how bright the LEDs are.

I got a bit stuck with the motors because I didn't realize I'd need to sand the sides of the motors. Using the edge of a coin doesn't work to sand it, something like medium grade sandpaper at least, might work. Then the sides of the motors were soldered onto the board. Which I still don't know why. As in, is it for stabilizing the motors or for actually letting electricity flow through the sides which were previously coated before being sanded. Also, in case anyone wants to know, they are submarine motors with a chasis.

Finished Running Microbug
So, then I had everything soldered on and I put in some brand new batteries and the circuit didn't work. I fiddled around with it a bit, and I realized if I held the battery holder a certain way then one of the motors would rotate. I still haven't gotten the other half of the robot to work so it's not a good running bug, more like a flailing bug with one eye. Sometimes I got both eyes to work. Other times only the eye on the same side as the motor turned on. Twisting the knob in the potentiometer definitely adjusted the bug's eyes, but didn't seem to have any effect on the motor speed. Also, the motor stopped for sure when the LDRs were covered up.

Now, I've built my first robot. It doesn't work well but it finally exists!

Sunday, June 28, 2015

Parser Project

I'm currently working on a project which will eventually need to parse commands or tasks into more usable intuitive responses which make it really easy for people to follow. But I don't know how to make a parser which can deal with organic language.

So I'm going to start looking into those Natural Language Processing APIs I posted a link to last year. Also, I need to learn more about Natural Language Processing itself. So I've got this online class from Columbia I can reference for introductory stuff.  http://www.cs.columbia.edu/~cs4705/ I hope it mentions how to implement some of this stuff. But looking at the initial material about grammars and trees, they will probably be implemented a lot like a compiler is made. But maybe just maybe it'll use deep learning neural networks so I need to look into that a bit since I know nothing about it other than it's a form of AI implementation.

If you know anything about these areas and can help, contact me because I would be glad to get any help on making these materials into code rather than just ideas and theory.

I'll probably use Markov chains in the first form of my parser.

Friday, May 22, 2015

Improving robotics knowledge

If my robotics knowledge is to go anywhere, I'm going to finally have to learn some math like summations and variables in equations. Also I need to do more coding and actual work with hardware. Later on down the line I can decide to specialize in robotics/ML, computer vision, or NLP. So far computer vision is behind while the other two areas are about equal.

8 Month Update (January 2016): After half a year of thought I have decided to specialize in the Natural Language Processing and the ML, AI bit of it eventually. But I just want to understand it for now. I'm also finally starting to learn those important math and coding problems.

Wednesday, April 22, 2015

Disable Auto Updates in Windows 8

In Windows 8, the default is an auto update. This is harmful when running the computer as a server or when in the middle of anything which is sensitive to turning off and on like 3D printing. Therefore, here is a tutorial on how to turn off the Windows auto updates.

Disable Auto Updates in Windows 8
1. In your search bar, type in Control Panel and pull it up.
2. Within your Control Panel, scroll until you find the Windows Update icon. Then click on it.
3. In the sidebar, locate Change settings.
4. Then a window will show with Important updates as a heading. Choose, Check for updates but let me choose whether to download and install them. Now you can know about updates and choose to install them only at a convenient times.

There you have it, now you can enjoy Windows 8 without interruptions to your 3D printing or show viewing pleasure.