Welcome back, ${authUser.username} 👋
+ + ` + + const page = template.content + + page.getElementById('logout-button') + .addEventListener('click', logout) + + return page +} + +function logout() { + localStorage.clear() + location.reload() +} + +``` + +This page greets the authenticated user and also has a logout button. The `logout()` function just clears `localStorage` and reloads the page. + +There is it. I bet you already saw the [demo][4] before. Also, the source code is in the same [repository][5]. + +👋👋👋 + +-------------------------------------------------------------------------------- + +via: https://nicolasparada.netlify.com/posts/passwordless-auth-client/ + +作者:[Nicolás Parada][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://nicolasparada.netlify.com/ +[1]:https://nicolasparada.netlify.com/posts/passwordless-auth-server/ +[2]:https://nicolasparada.netlify.com/posts/javascript-client-router/ +[3]:https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS +[4]:https://go-passwordless-demo.herokuapp.com/ +[5]:https://github.com/nicolasparada/go-passwordless-demo diff --git a/sources/tech/20180516 How to Read Outlook Emails by Python.md b/sources/tech/20180516 How to Read Outlook Emails by Python.md new file mode 100644 index 0000000000..36a000d010 --- /dev/null +++ b/sources/tech/20180516 How to Read Outlook Emails by Python.md @@ -0,0 +1,156 @@ +translating by lujun9972 +How to Read Outlook Emails by Python +====== + +![](https://process.filestackapi.com/cache=expiry:max/resize=width:700/compress/OVArLzhmRzOEQZsvGavF) + +when you start e-mail marketing , You need opt-in email address list. You have opt-in list. You are using email client software and If you can export your list from your email client, You will have good list. + +Now I am trying to explain my codes to write all emails into test file from your outlook profile. + +First you should import win32com.client, You need to install pywin32 +``` +pip install pywin32 + +``` + +We should connect to Outlook by MAPI +``` +outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI") + +``` + +Then we should get all accounts in your outlook profile. +``` +accounts= win32com.client.Dispatch("Outlook.Application").Session.Accounts; + +``` + +Then You need to get emails from inbox folder that is named emailleri_al. +``` +def emailleri_al(folder): + messages = folder.Items + a=len(messages) + if a>0: + for message2 in messages: + try: + sender = message2.SenderEmailAddress + if sender != "": + print(sender, file=f) + except: + print("Ben hatayım") + print(account.DeliveryStore.DisplayName) + pass + + try: + message2.Save + message2.Close(0) + except: + pass +``` + +You should go to all account and get inbox folder and get emails +``` +for account in accounts: + global inbox + inbox = outlook.Folders(account.DeliveryStore.DisplayName) + print("****Account Name**********************************",file=f) + print(account.DisplayName,file=f) + print(account.DisplayName) + print("***************************************************",file=f) + folders = inbox.Folders + + for folder in folders: + print("****Folder Name**********************************", file=f) + print(folder, file=f) + print("*************************************************", file=f) + emailleri_al(folder) + a = len(folder.folders) + + if a>0 : + global z + z = outlook.Folders(account.DeliveryStore.DisplayName).Folders(folder.name) + x = z.Folders + for y in x: + emailleri_al(y) + print("****Folder Name**********************************", file=f) + print("..."+y.name,file=f) + print("*************************************************", file= +``` + +All Code is as the following +``` +import win32com.client +import win32com +import os +import sys + +f = open("testfile.txt","w+") + +outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI") +accounts= win32com.client.Dispatch("Outlook.Application").Session.Accounts; + +def emailleri_al(folder): + messages = folder.Items + a=len(messages) + if a>0: + for message2 in messages: + try: + sender = message2.SenderEmailAddress + if sender != "": + print(sender, file=f) + except: + print("Error") + print(account.DeliveryStore.DisplayName) + pass + + try: + message2.Save + message2.Close(0) + except: + pass + + + +for account in accounts: + global inbox + inbox = outlook.Folders(account.DeliveryStore.DisplayName) + print("****Account Name**********************************",file=f) + print(account.DisplayName,file=f) + print(account.DisplayName) + print("***************************************************",file=f) + folders = inbox.Folders + + for folder in folders: + print("****Folder Name**********************************", file=f) + print(folder, file=f) + print("*************************************************", file=f) + emailleri_al(folder) + a = len(folder.folders) + + if a>0 : + global z + z = outlook.Folders(account.DeliveryStore.DisplayName).Folders(folder.name) + x = z.Folders + for y in x: + emailleri_al(y) + print("****Folder Name**********************************", file=f) + print("..."+y.name,file=f) + print("*************************************************", file=f) + + + +print("Finished Succesfully") +``` +-------------------------------------------------------------------------------- + +via: https://www.codementor.io/aliacetrefli/how-to-read-outlook-emails-by-python-jkp2ksk95 + +作者:[A.A. Cetrefli][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[lujun9972](https://github.com/lujun9972) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.codementor.io/aliacetrefli diff --git a/sources/tech/20180519 Python Debugging Tips.md b/sources/tech/20180519 Python Debugging Tips.md new file mode 100644 index 0000000000..0db53aa810 --- /dev/null +++ b/sources/tech/20180519 Python Debugging Tips.md @@ -0,0 +1,70 @@ +Python Debugging Tips +====== +When it comes to debugging, there’s a lot of choices that you can make. It is hard to give generic advice that always works (other than “Have you tried turning it off and back on?”). + +Here are a few of my favorite Python Debugging tips. + +### Make a branch + +Trust me on this. Even if you never intend to commit the changes back upstream, you will be glad your experiments are contained within their own branch. + +If nothing else, it makes cleanup a lot easier! + +### Install pdb++ + +Seriously. It makes you life easier if you are on the command line. + +All that pdb++ does is replace the standard pdb module with 100% PURE AWESOMENESS. Here’s what you get when you `pip install pdbpp`: + + * A Colorized prompt! + * tab completion! (perfect for poking around!) + * It slices! It dices! + + + +Ok, maybe the last one is a little bit much… But in all seriousness, installing pdb++ is well worth your time. + +### Poke around + +Sometimes the best approach is to just mess around and see what happens. Put a break point in an “obvious” spot and make sure it gets hit. Pepper the code with `print()` and/or `logging.debug()` statements and see where the code execution goes. + +Examine the arguments being passed into your functions. Check the versions of the libraries (if things are getting really desperate). + +### Only change one thing at a time + +Once you are poking around a bit you are going to get ideas on things you could do. But before you start slinging code, take a step back and think about what you could change, and then only change 1 thing. + +Once you’ve made the change, then test and see if you are closer to resolving the issue. If not, change the thing back, and try something else. + +Changing only one thing allows you to know what does and doesn’t work. Plus once you do get it working, your new commit is going to be much smaller (because there will be less changes). + +This is pretty much what one does in the Scientific Process: only change one variable at a time. By allowing yourself to see and measure the results of one change you will save your sanity and arrive at a working solution faster. + +### Assume nothing, ask questions + +Occasionally a developer (not you of course!) will be in a hurry and whip out some questionable code. When you go through to debug this code you need to stop and make sure you understand what it is trying to accomplish. + +Make no assumptions. Just because the code is in the `model.py` file doesn’t mean it won’t try to render some HTML. + +Likewise, double check all of your external connections before you do anything destructive! Going to delete some configuration data? MAKE SURE YOU ARE NOT CONNECTED TO YOUR PRODUCTION SYSTEM. + +### Be clever, but not too clever + +Sometimes we write code that is so amazingly awesome it is not obvious how it does what it does. + +While we might feel smart when we publish that code, more often than not we will wind up feeling dumb later on when the code breaks and we have to remember how it works to figure out why it isn’t working. + +Keep an eye out for any sections of code that look either overly complicated and long, or extremely short. These could be places where complexity is hiding and causing your bugs. + +-------------------------------------------------------------------------------- + +via: https://pythondebugging.com/articles/python-debugging-tips + +作者:[PythonDebugging.com][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://pythondebugging.com diff --git a/sources/tech/20180530 How to load or unload a Linux kernel module.md b/sources/tech/20180530 How to load or unload a Linux kernel module.md deleted file mode 100644 index d96b928aec..0000000000 --- a/sources/tech/20180530 How to load or unload a Linux kernel module.md +++ /dev/null @@ -1,190 +0,0 @@ -How to load or unload a Linux kernel module -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/code_computer_development_programming.png?itok=4OM29-82) - -This article is excerpted from chapter 15 of [Linux in Action][1], published by Manning. - -Linux manages hardware peripherals using kernel modules. Here's how that works. - -A running Linux kernel is one of those things you don't want to upset. After all, the kernel is the software that drives everything your computer does. Considering how many details have to be simultaneously managed on a live system, it's better to leave the kernel to do its job with as few distractions as possible. But if it's impossible to make even small changes to the compute environment without rebooting the whole system, then plugging in a new webcam or printer could cause a painful disruption to your workflow. Having to reboot each time you add a device to get the system to recognize it is hardly efficient. - -To create an effective balance between the opposing virtues of stability and usability, Linux isolates the kernel, but lets you add specific functionality on the fly through loadable kernel modules (LKMs). As shown in the figure below, you can think of a module as a piece of software that tells the kernel where to find a device and what to do with it. In turn, the kernel makes the device available to users and processes and oversees its operation. - -![Kernel modules][3] - -Kernel modules act as translators between devices and the Linux kernel. - -There's nothing stopping you from writing your own module to support a device exactly the way you'd like it, but why bother? The Linux module library is already so robust that there's usually no need to roll your own. And the vast majority of the time, Linux will automatically load a new device's module without you even knowing it. - -Still, there are times when, for some reason, it doesn't happen by itself. (You don't want to leave that hiring manager impatiently waiting for your smiling face to join the video conference job interview for too long.) To help things along, you'll want to understand a bit more about kernel modules and, in particular, how to find the actual module that will run your peripheral and then how to manually activate it. - -### Finding kernel modules - -By accepted convention, modules are files with a .ko (kernel object) extension that live beneath the `/lib/modules/` directory. Before you navigate all the way down to those files, however, you'll probably have to make a choice. Because you're given the option at boot time of loading one from a list of releases, the specific software needed to support your choice (including the kernel modules) has to exist somewhere. Well, `/lib/modules`/ is one of those somewheres. And that's where you'll find directories filled with the modules for each available Linux kernel release; for example: -``` -$ ls /lib/modules - -4.4.0-101-generic - -4.4.0-103-generic - -4.4.0-104-generic - -``` - -In my case, the active kernel is the version with the highest release number (4.4.0-104-generic), but there's no guarantee that that'll be the same for you (kernels are frequently updated). If you're going to be doing some work with modules that you'd like to use on a live system, you need to be sure you've got the right directory tree. - -`uname -r` (the `-r` specifies the kernel release number from within the system information that would normally be displayed): -``` -$ uname -r - -4.4.0-104-generic - -``` - -Good news: there's a reliable trick. Rather than identifying the directory by name and hoping you'll get the right one, use the system variable that always points to the name of the active kernel. You can invoke that variable using(thespecifies the kernel release number from within the system information that would normally be displayed): - -With that information, you can incorporate `uname` into your filesystem references using a process known as command substitution. To navigate to the right directory, for instance, you'd add it to `/lib/modules`. To tell Linux that "uname" isn't a filesystem location, enclose the `uname` part in backticks, like this: -``` -$ ls /lib/modules/`uname -r` - -build modules.alias modules.dep modules.softdep - -initrd modules.alias.bin modules.dep.bin modules.symbols - -kernel modules.builtin modules.devname modules.symbols.bin - -misc modules.builtin.bin modules.order vdso - -``` - -You'll find most of the modules organized within their subdirectories beneath the `kernel/` directory. Take a few minutes to browse through those directories to get an idea of how things are arranged and what's available. The filenames usually give you a good idea of what you're looking at. -``` -$ ls /lib/modules/`uname -r`/kernel - -arch crypto drivers fs kernel lib mm - -net sound ubuntu virt zfs - -``` - -That's one way to locate kernel modules; actually, it's the quick and dirty way to go about it. But it's not the only way. If you want to get the complete set, you can list all currently loaded modules, along with some basic information, by using `lsmod`. The first column of this truncated output (there would be far too many to list here) is the module name, followed by the file size and number, and then the names of other modules on which each is dependent: -``` -$ lsmod - -[...] - -vboxdrv 454656 3 vboxnetadp,vboxnetflt,vboxpci - -rt2x00usb 24576 1 rt2800usb - -rt2800lib 94208 1 rt2800usb - -[...] - -``` - -How many are far too many? Well, let's run `lsmod` once again, but this time piping the output to `wc -l` to get a count of the lines: -``` -$ lsmod | wc -l - -113 - -``` - -Those are the loaded modules. How many are available in total? Running `modprobe -c` and counting the lines will give us that number: -``` -$ modprobe -c | wc -l - -33350 - -``` - -There are 33,350 available modules!?! It looks like someone's been working hard over the years to provide us with the software to run our physical devices. - -Note: On some systems, you might encounter customized modules that are referenced either with their unique entries in the `/etc/modules` file or as a configuration file saved to `/etc/modules-load.d/`. The odds are that such modules are the product of local development projects, perhaps involving cutting-edge experiments. Either way, it's good to have some idea of what it is you're looking at. - -That's how you find modules. Your next job is to figure out how to manually load an inactive module if, for some reason, it didn't happen on its own. - -### Manually loading kernel modules - -Before you can load a kernel module, logic dictates that you'll have to confirm it exists. And before you can do that, you'll need to know what it's called. Getting that part sometimes requires equal parts magic and luck and some help from of the hard work of online documentation authors. - -I'll illustrate the process by describing a problem I ran into some time back. One fine day, for a reason that still escapes me, the WiFi interface on a laptop stopped working. Just like that. Perhaps a software update knocked it out. Who knows? I ran `lshw -c network` and was treated to this very strange information: -``` -network UNCLAIMED - - AR9485 Wireless Network Adapter - -``` - -Linux recognized the interface (the Atheros AR9485) but listed it as unclaimed. Well, as they say, "When the going gets tough, the tough search the internet." I ran a search for atheros ar9 linux module and, after sifting through pages and pages of five- and even 10-year-old results advising me to either write my own module or just give up, I finally discovered that (with Ubuntu 16.04, at least) a working module existed. Its name is ath9k. - -Yes! The battle's as good as won! Adding a module to the kernel is a lot easier than it sounds. To double check that it's available, you can run `find` against the module's directory tree, specify `-type f` to tell Linux you're looking for a file, and then add the string `ath9k` along with a glob asterisk to include all filenames that start with your string: -``` -$ find /lib/modules/$(uname -r) -type f -name ath9k* - -/lib/modules/4.4.0-97-generic/kernel/drivers/net/wireless/ath/ath9k/ath9k_common.ko - -/lib/modules/4.4.0-97-generic/kernel/drivers/net/wireless/ath/ath9k/ath9k.ko - -/lib/modules/4.4.0-97-generic/kernel/drivers/net/wireless/ath/ath9k/ath9k_htc.ko - -/lib/modules/4.4.0-97-generic/kernel/drivers/net/wireless/ath/ath9k/ath9k_hw.ko - -``` - -Just one more step, load the module: -``` -# modprobe ath9k - -``` - -That's it. No reboots. No fuss. - -Here's one more example to show you how to work with active modules that have become corrupted. There was a time when using my Logitech webcam with a particular piece of software would make the camera inaccessible to any other programs until the next system boot. Sometimes I needed to open the camera in a different application but didn't have the time to shut down and start up again. (I run a lot of applications, and getting them all in place after booting takes some time.) - -Because this module is presumably active, using `lsmod` to search for the word video should give me a hint about the name of the relevant module. In fact, it's better than a hint: The only module described with the word video is uvcvideo (as you can see in the following): -``` -$ lsmod | grep video - -uvcvideo 90112 0 - -videobuf2_vmalloc 16384 1 uvcvideo - -videobuf2_v4l2 28672 1 uvcvideo - -videobuf2_core 36864 2 uvcvideo,videobuf2_v4l2 - -videodev 176128 4 uvcvideo,v4l2_common,videobuf2_core,videobuf2_v4l2 - -media 24576 2 uvcvideo,videodev - -``` - -There was probably something I could have controlled for that was causing the crash, and I guess I could have dug a bit deeper to see if I could fix things the right way. But you know how it is; sometimes you don't care about the theory and just want your device working. So I used `rmmod` to kill the uvcvideo module and `modprobe` to start it up again all nice and fresh: -``` -# rmmod uvcvideo - -# modprobe uvcvideo - -``` - -Again: no reboots. No stubborn blood stains. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/5/how-load-or-unload-linux-kernel-module - -作者:[David Clinto][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://opensource.com/users/dbclinton -[1]:https://www.manning.com/books/linux-in-action?a_aid=bootstrap-it&a_bid=4ca15fc9&chan=opensource -[2]:/file/397906 -[3]:https://opensource.com/sites/default/files/uploads/kernels.png (Kernel modules) diff --git a/sources/tech/20180611 3 open source alternatives to Adobe Lightroom.md b/sources/tech/20180611 3 open source alternatives to Adobe Lightroom.md new file mode 100644 index 0000000000..664c054913 --- /dev/null +++ b/sources/tech/20180611 3 open source alternatives to Adobe Lightroom.md @@ -0,0 +1,84 @@ +3 open source alternatives to Adobe Lightroom +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/camera-photography-film.jpg?itok=oe2ixyu6) + +You wouldn't be wrong to wonder whether the smartphone, that modern jack-of-all-trades, is taking over photography. While that might be valid in the point-and-shoot camera market, there are a sizeable number of photography professionals and hobbyists who recognize that a camera that fits in your pocket can never replace a high-end DSLR camera and the depth, clarity, and realism of its photos. + +All of that power comes with a small price in terms of convenience; like negatives from traditional film cameras, the [raw image][1] files produced by DSLRs must be processed before they can be edited or printed. For this, a digital image processing application is indispensable, and the go-to application has been Adobe Lightroom. But for many reasons—including its expensive, subscription-based pricing model and its proprietary license—there's a lot of interest in open source and other alternatives. + +Lightroom has two main functions: processing raw image files and digital asset management (DAM)—organizing images with tags, ratings, and other metadata to make it easier to keep track of them. + +In this article, we'll look at three open source image processing applications: Darktable, LightZone, and RawTherapee. All of them have DAM capabilities, but none has Lightroom's machine learning-based image categorization and tagging features. If you're looking for more information about open source DAM software, check out Terry Hancock's article "[Digital asset management for an open movie project][2]," where he shares his research on software to organize multimedia files for his [_Lunatics!_][3] open movie project. + +### Darktable + +![Darktable][4] + +Like the other applications on our list, [darktable][5] processes raw images into usable file formats—it exports into JPEG, PNG, TIFF, PPM, PFM, and EXR, and it also supports Google and Facebook web albums, Flickr uploads, email attachments, and web gallery creation. + +Its 61 image operation modules allow you to adjust contrast, tone, exposure, color, noise, etc.; add watermarks; crop and rotate; and much more. As with the other applications described in this article, those edits are "non-destructive"—that is, your original raw image is preserved no matter how many tweaks and modifications you make. + +Darktable imports raw images from more than 400 cameras plus JPEG, CR2, DNG, OpenEXR, and PFM; images are managed in a database so you can filter and search using metadata including tags, ratings, and color. It's also available in 21 languages and is supported on Linux, MacOS, BSD, Solaris 11/GNOME, and Windows. (The [Windows port][6] is new, and darktable warns it may have "rough edges or missing functionality" compared to other versions.) + +Darktable is licensed under [GPLv3][7]; you can learn more by perusing its [features][8], viewing the [user manual][9], or accessing its [source code][10] on GitHub. + +### LightZone + +![LightZone's tool stack][11] + +As a non-destructive raw image processing tool, [LightZone][12] is similar to the other two applications on this list: it's cross-platform, operating on Windows, MacOS, and Linux, and it supports JPG and TIFF images in addition to raw. But it's also unique in several ways. + +For one thing, it started out in 2005 as a proprietary image processing tool and later became an open source project under a BSD license. Also, before you can download the application, you must register for a free account; this is so the LightZone development community can track downloads and build the community. (Approval is quick and automated, so it's not a large barrier.) + +Another difference is that image modifications are done using stackable tools, rather than filters (like most image-editing applications); tool stacks can be rearranged or removed, as well as saved and copied to a batch of images. You can also edit certain parts of an image using a vector-based tool or by selecting pixels based on color or brightness. + +You can get more information on LightZone by searching its [forums][13] or accessing its [source code][14] on GitHub. + +### RawTherapee + +![RawTherapee][15] + +[RawTherapee][16] is another popular open source ([GPL][17]) raw image processor worth your attention. Like darktable and LightZone, it is cross-platform (Windows, MacOS, and Linux) and implements edits in a non-destructive fashion, so you maintain access to your original raw image file no matter what filters or changes you make. + +RawTherapee uses a panel-based interface, including a history panel to keep track of your changes and revert to a previous point; a snapshot panel that allows you to work with multiple versions of a photo; and scrollable tool panels to easily select a tool without worrying about accidentally using the wrong one. Its tools offer a wide variety of exposure, color, detail, transformation, and demosaicing features. + +The application imports raw files from most cameras and is localized to more than 25 languages, making it widely usable. Features like batch processing and [SSE][18] optimizations improve speed and CPU performance. + +RawTherapee offers many other [features][19]; check out its [documentation][20] and [source code][21] for details. + +Do you use another open source raw image processing tool in your photography? Do you have any related tips or suggestions for other photographers? If so, please share your recommendations in the comments. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/alternatives/adobe-lightroom + +作者:[Opensource.com][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com +[1]:https://en.wikipedia.org/wiki/Raw_image_format +[2]:https://opensource.com/article/18/3/movie-open-source-software +[3]:http://lunatics.tv/ +[4]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/uploads/raw-image-processors_darkroom1.jpg?itok=0fjk37tC (Darktable) +[5]:http://www.darktable.org/ +[6]:https://www.darktable.org/about/faq/#faq-windows +[7]:https://github.com/darktable-org/darktable/blob/master/LICENSE +[8]:https://www.darktable.org/about/features/ +[9]:https://www.darktable.org/resources/ +[10]:https://github.com/darktable-org/darktable +[11]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/uploads/raw-image-processors_lightzone1tookstack.jpg?itok=1e3s85CZ (LightZone's tool stack) +[12]:http://www.lightzoneproject.org/ +[13]:http://www.lightzoneproject.org/Forum +[14]:https://github.com/ktgw0316/LightZone +[15]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/uploads/raw-image-processors_rawtherapee.jpg?itok=meiuLxPw (RawTherapee) +[16]:http://rawtherapee.com/ +[17]:https://github.com/Beep6581/RawTherapee/blob/dev/LICENSE.txt +[18]:https://en.wikipedia.org/wiki/Streaming_SIMD_Extensions +[19]:http://rawpedia.rawtherapee.com/Features +[20]:http://rawpedia.rawtherapee.com/Main_Page +[21]:https://github.com/Beep6581/RawTherapee diff --git a/sources/tech/20180611 How to partition a disk in Linux.md b/sources/tech/20180611 How to partition a disk in Linux.md new file mode 100644 index 0000000000..8ed451d114 --- /dev/null +++ b/sources/tech/20180611 How to partition a disk in Linux.md @@ -0,0 +1,185 @@ +How to partition a disk in Linux +====== +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/bus-storage.png?itok=95-zvHYl) + +Creating and deleting partitions in Linux is a regular practice because storage devices (such as hard drives and USB drives) must be structured in some way before they can be used. In most cases, large storage devices are divided into separate sections called partitions. Partitioning also allows you to divide your hard drive into isolated sections, where each section behaves as its own hard drive. Partitioning is particularly useful if you run multiple operating systems. + +There are lots of powerful tools for creating, removing, and otherwise manipulating disk partitions in Linux. In this article, I'll explain how to use the `parted` command, which is particularly useful with large disk devices and many disk partitions. Differences between `parted` and the more common `fdisk` and `cfdisk` commands include: + + * **GPT format:** The `parted` command can create a Globally Unique Identifiers Partition Table [GPT][1]), while `fdisk` and `cfdisk` are limited to DOS partition tables. + * **Larger disks:** A DOS partition table can format up to 2TB of disk space, although up to 16TB is possible in some cases. However, a GPT partition table can address up to 8ZiB of space. + * **More partitions:** Using primary and extended partitions, DOS partition tables allow only 16 partitions. With GPT, you get up to 128 partitions by default and can choose to have many more. + * **Reliability:** Only one copy of the partition table is stored in a DOS partition. GPT keeps two copies of the partition table (at the beginning and the end of the disk). The GPT also uses a [CRC][2] checksum to check the partition table integrity, which is not done with DOS partitions. + + + +With today's larger disks and the need for more flexibility in working with them, using `parted` to work with disk partitions is recommended. Most of the time, disk partition tables are created as part of the operating system installation process. Direct use of the `parted` command is most useful when adding a storage device to an existing system. + +### Give 'parted' a try + +`parted` command. To try these steps, I strongly recommend using a brand new storage device or one where you don't mind wiping out the contents. + +The following explains the process of partitioning a storage device with thecommand. To try these steps, I strongly recommend using a brand new storage device or one where you don't mind wiping out the contents. + +**1\. List the partitions:** Use `parted -l` to identify the storage device you want to partition. Typically, the first hard disk (`/dev/sda` or `/dev/vda`) will contain the operating system, so look for another disk to find the one you want (e.g., `/dev/sdb`, `/dev/sdc`, `/dev/vdb`, `/dev/vdc`, etc.). +``` +$ sudo parted -l + +[sudo] password for daniel: + +Model: ATA RevuAhn_850X1TU5 (scsi) + +Disk /dev/vdc: 512GB + +Sector size (logical/physical): 512B/512B + +Partition Table: msdos + +Disk Flags: + + + +Number Start End Size Type File system Flags + + 1 1049kB 525MB 524MB primary ext4 boot + + 2 525MB 512GB 512GB primary lvm + +``` + +**2\. Open the storage device:** Use `parted` to begin working with the selected storage device. In this example, the device is the third disk on a virtual system (`/dev/vdc`). It is important to indicate the specific device you want to use. If you just type `parted` with no device name, it will randomly select a storage device to modify. +``` +$ sudo parted /dev/vdc + +GNU Parted 3.2 + +Using /dev/vdc + +Welcome to GNU Parted! Type 'help' to view a list of commands. + +(parted) + +``` + +**3\. Set the partition table:** Set the partition table type to GPT, then type "Yes" to accept it. +``` +(parted) mklabel gpt + +Warning: the existing disk label on /dev/vdc will be destroyed + +and all data on this disk will be lost. Do you want to continue? + +Yes/No? Yes + +``` + +The `mklabel` and `mktable` commands are used for the same purpose (making a partition table on a storage device). The supported partition tables are: aix, amiga, bsd, dvh, gpt, mac, ms-dos, pc98, sun, and loop. Remember `mklabel` will not make a partition, rather it will make a partition table. + +**4\. Review the partition table:** Show information about the storage device. +``` +(parted) print + +Model: Virtio Block Device (virtblk) + +Disk /dev/vdc: 1396MB + +Sector size (logical/physical): 512B/512B + +Partition Table: gpt + +Disk Flags: + +Number Start End Size File system Name Flags + +``` + +**5\. Get help:** To find out how to make a new partition, type: `(parted) help mkpart`. +``` +(parted) help mkpart + + mkpart PART-TYPE [FS-TYPE] START END make a partition + + + + PART-TYPE is one of: primary, logical, extended + + FS-TYPE is one of: btrfs, nilfs2, ext4, ext3, ext2, fat32, fat16, hfsx, hfs+, hfs, jfs, swsusp, + + linux-swap(v1), linux-swap(v0), ntfs, reiserfs, hp-ufs, sun-ufs, xfs, apfs2, apfs1, asfs, amufs5, + + amufs4, amufs3, amufs2, amufs1, amufs0, amufs, affs7, affs6, affs5, affs4, affs3, affs2, affs1, + + affs0, linux-swap, linux-swap(new), linux-swap(old) + + START and END are disk locations, such as 4GB or 10%. Negative values count from the end of the + + disk. For example, -1s specifies exactly the last sector. + + + + 'mkpart' makes a partition without creating a new file system on the partition. FS-TYPE may be + + specified to set an appropriate partition ID. + +``` + +**6\. Make a partition:** To make a new partition (in this example, 1,396MB on partition 0), type the following: +``` +(parted) mkpart primary 0 1396MB + + + +Warning: The resulting partition is not properly aligned for best performance + +Ignore/Cancel? I + + + +(parted) print + +Model: Virtio Block Device (virtblk) + +Disk /dev/vdc: 1396MB + +Sector size (logical/physical): 512B/512B + +Partition Table: gpt + +Disk Flags: + +Number Start End Size File system Name Flags + +1 17.4kB 1396MB 1396MB primary + +``` + +Filesystem type (fstype) will not create an ext4 filesystem on `/dev/vdc1`. A DOS partition table's partition types are primary, logical, and extended. In a GPT partition table, the partition type is used as the partition name. Providing a partition name under GPT is a must; in the above example, primary is the name, not the partition type. + +**7\. Save and quit:** Changes are automatically saved when you quit `parted`. To quit, type the following: +``` +(parted) quit + +Information: You may need to update /etc/fstab. + +$ + +``` + +### Words to the wise + +Make sure to identify the correct disk before you begin changing its partition table when you add a new storage device. If you mistakenly change the disk partition that contains your computer's operating system, you could make your system unbootable. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/6/how-partition-disk-linux + +作者:[Daniel Oh][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/daniel-oh +[1]:https://en.wikipedia.org/wiki/GUID_Partition_Table +[2]:https://en.wikipedia.org/wiki/Cyclic_redundancy_check diff --git a/sources/tech/20180611 Turn Your Raspberry Pi into a Tor Relay Node.md b/sources/tech/20180611 Turn Your Raspberry Pi into a Tor Relay Node.md new file mode 100644 index 0000000000..4ca5834bd8 --- /dev/null +++ b/sources/tech/20180611 Turn Your Raspberry Pi into a Tor Relay Node.md @@ -0,0 +1,133 @@ +Turn Your Raspberry Pi into a Tor Relay Node +====== + +![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/tor-onion-router.jpg?itok=6WUl0ElH) + +If you’re anything like me, you probably got yourself a first- or second-generation Raspberry Pi board when they first came out, played with it for a while, but then shelved it and mostly forgot about it. After all, unless you’re a robotics enthusiast, you probably don’t have that much use for a computer with a pretty slow processor and 256 megabytes of RAM. This is not to say that there aren’t cool things you can do with one of these, but between work and other commitments, I just never seem to find the right time for some good old nerding out. + +However, if you would like to put it to good use without sacrificing too much of your time or resources, you can turn your old Raspberry Pi into a perfectly functioning Tor relay node. + +### What is a Tor Relay node + +You have probably heard about the [Tor project][1] before, but just in case you haven’t, here’s a very quick summary. The name “Tor” stands for “The Onion Router” and it is a technology created to combat online tracking and other privacy violations. + +Everything you do on the Internet leaves a set of digital footprints in every piece of equipment that your IP packets traverse: all of the switches, routers, load balancers and destination websites log the IP address from which your session originated and the IP address of the internet resource you are accessing (and often its hostname, [even when using HTTPS][2]). If you’re browsing from home, then your IP can be directly mapped to your household. If you’re using a VPN service ([as you should be][3]), then your IP can be mapped to your VPN provider, and then they are the ones who can map it to your household. In any case, odds are that someone somewhere is assembling an online profile on you based on the sites you visit and how much time you spend on each of them. Such profiles are then sold, aggregated with matching profiles collected from other services, and then monetized by ad networks. At least, that’s the optimist’s view of how that data is used -- I’m sure you can think of many examples of how your online usage profiles can be used against you in much more nefarious ways. + +The Tor project attempts to provide a solution to this problem by making it impossible (or, at least, unreasonably difficult) to trace the endpoints of your IP session. Tor achieves this by bouncing your connection through a chain of anonymizing relays, consisting of an entry node, relay node, and exit node: + + 1. The **entry node** only knows your IP address, and the IP address of the relay node, but not the final destination of the request; + + 2. The **relay node** only knows the IP address of the entry node and the IP address of the exit node, and neither the origin nor the final destination + + 3. The **exit node** **** only knows the IP address of the relay node and the final destination of the request; it is also the only node that can decrypt the traffic before sending it over to its final destination + + + + +Relay nodes play a crucial role in this exchange because they create a cryptographic barrier between the source of the request and the destination. Even if exit nodes are controlled by adversaries intent on stealing your data, they will not be able to know the source of the request without controlling the entire Tor relay chain. + +As long as there are plenty of relay nodes, your privacy when using the Tor network remains protected -- which is why I heartily recommend that you set up and run a relay node if you have some home bandwidth to spare. + +#### Things to keep in mind regarding Tor relays + +A Tor relay node only receives encrypted traffic and sends encrypted traffic -- it never accesses any other sites or resources online, so you do not need to worry that someone will browse any worrisome sites directly from your home IP address. Having said that, if you reside in a jurisdiction where offering anonymity-enhancing services is against the law, then, obviously, do not operate your own Tor relay. You may also want to check if operating a Tor relay is against the terms and conditions of your internet access provider. + +### What you will need + + * A Raspberry Pi (any model/generation) with some kind of enclosure + + * An SD card with [Raspbian Stretch Lite][4] + + * An ethernet cable + + * A micro-USB cable for power + + * A keyboard and an HDMI-capable monitor (to use during the setup) + + + + +This guide will assume that you are setting this up on your home connection behind a generic cable or ADSL modem router that performs NAT translation (and it almost certainly does). Most of them have a USB port you can use to power up your Raspberry Pi, and if you’re only using the wifi functionality of the router, then it should have a free ethernet port for you to plug into. However, before we get to the point where we can set-and-forget your Raspberry Pi, we’ll need to set it up as a Tor relay node, for which you’ll need a keyboard and a monitor. + +### The bootstrap script + +I’ve adapted a popular Tor relay node bootstrap script for use with Raspbian Stretch -- you can find it in my GitHub repository here: