Posts

Showing posts from October, 2017

Brew Install Nvm. Nvm: Command Not Found

Answer : There are two steps to installing nvm with brew. First use brew to install the application: brew install nvm Then take a look at the brew info "caveats" section, to see what else you have to do: brew info nvm You might see something like (this can change!): You should create NVM's working directory if it doesn't exist: mkdir ~/.nvm Add the following to ~/.bash_profile or your desired shell configuration file: export NVM_DIR="$HOME/.nvm" . "/usr/local/opt/nvm/nvm.sh" If you do not have a ~/.bash_profile file, then you can simply create one. Make sure to restart your terminal before trying the command. From the docs: Your system may not have a [.bash_profile file] where the command is set up. Simply create one with touch ~/.bash_profile and run the install script again you might need to restart your terminal instance. Try opening a new tab/window in your terminal and retry. Restarting worked f

Border Div Bootstrap 4 Code Example

Example 1: border radius bootstrap Border-radius Add classes to an element to easily round its corners. <img src= "..." alt= "..." class= "rounded" > <img src= "..." alt= "..." class= "rounded-top" > <img src= "..." alt= "..." class= "rounded-right" > <img src= "..." alt= "..." class= "rounded-bottom" > <img src= "..." alt= "..." class= "rounded-left" > <img src= "..." alt= "..." class= "rounded-circle" > <img src= "..." alt= "..." class= "rounded-0" > Example 2: border bottom class in bootstrap 4 <span class= "border" ></span> <span class= "border-top" ></span> <span class= "border-right" ></span> <span class= "border-bottom" ></span

2D Peak Finding Algorithm In O(n) Worst Case Time?

Answer : Let's assume that width of the array is bigger than height, otherwise we will split in another direction. Split the array into three parts: central column, left side and right side. Go through the central column and two neighbour columns and look for maximum. If it's in the central column - this is our peak If it's in the left side, run this algorithm on subarray left_side + central_column If it's in the right side, run this algorithm on subarray right_side + central_column Why this works: For cases where the maximum element is in the central column - obvious. If it's not, we can step from that maximum to increasing elements and will definitely not cross the central row, so a peak will definitely exist in the corresponding half. Why this is O(n): step #3 takes less than or equal to max_dimension iterations and max_dimension at least halves on every two algorithm steps. This gives n+n/2+n/4+... which is O(n) . Important detail: we split

10 Fastfingers.com Code Example

Example: tenfastfingers when you want to test you typing speed go to tenfastfingers lol

Android Image Scale Animation Relative To Center Point

Answer : 50% is center of animated view. 50%p is center of parent <scale android:fromXScale="1.0" android:toXScale="1.2" android:fromYScale="1.0" android:toYScale="1.2" android:pivotX="50%" android:pivotY="50%" android:duration="175"/> The answer provided by @stevanveltema and @JiangQi are perfect but if you want scaling using code, then you can use my answer. // first 0f, 1f mean scaling from X-axis to X-axis, meaning scaling from 0-100% // first 0f, 1f mean scaling from Y-axis to Y-axis, meaning scaling from 0-100% // The two 0.5f mean animation will start from 50% of X-axis & 50% of Y-axis, i.e. from center ScaleAnimation fade_in = new ScaleAnimation(0f, 1f, 0f, 1f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); fade_in.setDuration(1000); // animation duration in milliseconds fade_in.setFillAfter(true); // If fillAfter is true, the tr

Can't Use External IP On Hetzner VPS

Answer : Hetzner had stopped assigning public IPv4 addresses to virtual servers. As far as I can tell this change happened when they changed the product name from VQ to CX. The usage of NAT is not mentioned in the product description though. Eventually Hetzner introduced a newer cloud platform in which VMs get real public IPv4 addresses and a routed /64 IPv6 prefix. Both versions share the CX name. Virtual servers ordered in 2012 and 2013 would keep their public IPv4 address until 2019 when the VQ line was discontinued. But virtual servers ordered in 2016 only have an RFC1918 address, and Hetzner will not route a public IPv4 address to such a virtual server. They still allocated a dedicated public IPv4 address to each virtual server, which they NAT to the assigned RFC1918 address. Hetzner believed this was not a problem because it was a 1:1 NAT. As you found out, this is error prone when configuring the server. You have to know about this NAT. And you have to look up the map

Cpp Compile Online Code Example

Example 1: c++ online compiler This two are good C ++ compilers : https : //www.onlinegdb.com/online_c++_compiler https : //www.programiz.com/cpp-programming/online-compiler/ Example 2: cpp online compiler Best Site With auto compile : https : //godbolt.org/z/nEo4j7

Composer Update Laravel

Answer : When you run composer update , composer generates a file called composer.lock which lists all your packages and the currently installed versions. This allows you to later run composer install , which will install the packages listed in that file, recreating the environment that you were last using. It appears from your log that some of the versions of packages that are listed in your composer.lock file are no longer available. Thus, when you run composer install , it complains and fails. This is usually no big deal - just run composer update and it will attempt to build a set of packages that work together and write a new composer.lock file. However, you're running into a different problem. It appears that, in your composer.json file, the original developer has added some pre- or post- update actions that are failing, specifically a php artisan migrate command. This can be avoided by running the following: composer update --no-scripts This will run the compos

BLIZZARD LOGIN Code Example

Example: battle.net Blizzard Battle . net is an Internet - based online gaming , social networking , digital distribution , and digital rights management platform developed by Blizzard Entertainment .

Can A TensorFlow Hub Module Be Used In TensorFlow 2.0?

Answer : In Tensorflow 2.0 you should be using hub.load() or hub.KerasLayer() . [April 2019] - For now only Tensorflow 2.0 modules are loadable via them. In the future many of 1.x Hub modules should be loadable as well. For the 2.x only modules you can see examples in the notebooks created for the modules here this function load will work with tensorflow 2 embed = hub.load("https://tfhub.dev/google/universal-sentence-encoder-large/3") instead of embed = hub.Module("https://tfhub.dev/google/universal-sentence-encoder-large/3") [this is not accepted in tf2] use hub.load()

Add Request.GET Variable Using Django.shortcuts.redirect

Answer : Since redirect just returns an HttpResponseRedirect object, you could just alter that: response = redirect('url-name', x) response['Location'] += '?your=querystring' return response Is possible to add GET variables in a redirect ? (Without having to modifiy my urls.py) I don't know of any way to do this without modifying the urls.py . I don't have complains using HttpResponseRedirect('/my_long_url/%s/?q=something', x) instead, but just wondering... You might want to write a thin wrapper to make this easier. Say, custom_redirect def custom_redirect(url_name, *args, **kwargs): from django.core.urlresolvers import reverse import urllib url = reverse(url_name, args = args) params = urllib.urlencode(kwargs) return HttpResponseRedirect(url + "?%s" % params) This can then be called from your views. For e.g. return custom_redirect('url-name', x, q = 'something') # Should

Can I Loop Through A Table Variable In T-SQL?

Answer : Add an identity to your table variable, and do an easy loop from 1 to the @@ROWCOUNT of the INSERT-SELECT. Try this: DECLARE @RowsToProcess int DECLARE @CurrentRow int DECLARE @SelectCol1 int DECLARE @table1 TABLE (RowID int not null primary key identity(1,1), col1 int ) INSERT into @table1 (col1) SELECT col1 FROM table2 SET @RowsToProcess=@@ROWCOUNT SET @CurrentRow=0 WHILE @CurrentRow<@RowsToProcess BEGIN SET @CurrentRow=@CurrentRow+1 SELECT @SelectCol1=col1 FROM @table1 WHERE RowID=@CurrentRow --do your thing here-- END DECLARE @table1 TABLE ( idx int identity(1,1), col1 int ) DECLARE @counter int SET @counter = 1 WHILE(@counter < SELECT MAX(idx) FROM @table1) BEGIN DECLARE @colVar INT SELECT @colVar = col1 FROM @table1 WHERE idx = @counter -- Do your work here SET @counter = @counter + 1 END Believe it or not, this is actually more efficient and performant than using a cursor.

Sprintf Arduino Float Code Example

Example: arduino sprintf float // On arduino, sprintf does not support formatting floats, but it can be done // with some simple integer formatting: float f = 3.14 ; sprintf ( str , "Float value: %d.%02d" , ( int ) f , ( int ) ( fabsf ( f ) * 100 ) % 100 ) ; // str will now be: "Float value: 3.14"

Can I Use Font-awesome Icons On Emails

Answer : You can't use webfonts reliably in html emails. Some clients might respect and render them, but the majority don't. You can use this website to convert the icons into images, and then simply download the images and upload them to Imgur. From there you can use <img> tags to link to the Imgur images. Edit: A better solution would be to host the images on your own server with the same domain as your email's domain . This will increase the chance of images automatically being displayed on your emails, as they are normally hidden until the user decides to view them. For example, if I used myname@mydomain.com to send emails, I'd host the images on mydomain.com You can embed them as images in your email. You can use fa2png.io which converts the font awesome icons to png of required size as well as color.

Css Text Horizontal Align Right Code Example

Example: center text in css .class { text-align: center; }

C++ To Mips Converter Online Code Example

Example: convert c++ to mips assembly code online # Not sure what to do now ? Enter your mips code here

Can't Perform A React State Update On An Unmounted Component

Answer : Here is a React Hooks specific solution for Error Warning: Can't perform a React state update on an unmounted component. Solution You can declare let isMounted = true inside useEffect , which will be changed in the cleanup callback, as soon as the component is unmounted. Before state updates, you now check this variable conditionally: useEffect(() => { let isMounted = true; // note this flag denote mount status someAsyncOperation().then(data => { if (isMounted) setState(data); }) return () => { isMounted = false }; // use effect cleanup to set flag false, if unmounted }); const Parent = () => { const [mounted, setMounted] = useState(true); return ( <div> Parent: <button onClick={() => setMounted(!mounted)}> {mounted ? "Unmount" : "Mount"} Child </button> {mounted && <Child />} <p> Unmount Child, while it is still

Android: Mkdirs()/mkdir() On External Storage Returns False

Image
Answer : I got the same problem,and I am sure I had put the permission tag in the right place,but mkdirs didn't work yet, my system is Android 6.0, I resolve it now , you can check as below: make sure your put the permission tag in . open "setting/application" in your phone,check your application's permission(I found the permission in my manifest statement is not here),open the switch of the permission like this.(I found it is closed in default which make "mkdirs" failed) I have had the same problem and I have searched everything for a week trying to find the answer. I think I found it and I think it's ridiculously easy, you have to put the uses-permission statement in the right place... <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.company.name" android:versionCode="1" android:versionName="0

14 Minute Timer Code Example

Example: 20 minute timer for good eyesight every 20 minutes look out the window at something 20 feet away for 20 seconds