Posts

Showing posts from November, 2013

AWS Sts Assume Role In One Command

Answer : Finally, a colleague shared with me this awesome snippet that gets the work done in one go: eval $(aws sts assume-role --role-arn arn:aws:iam::123456789123:role/myAwesomeRole --role-session-name test | jq -r '.Credentials | "export AWS_ACCESS_KEY_ID=\(.AccessKeyId)\nexport AWS_SECRET_ACCESS_KEY=\(.SecretAccessKey)\nexport AWS_SESSION_TOKEN=\(.SessionToken)\n"') Apart from the AWS CLI, it only requires jq which is usually installed in any Linux Desktop. You can store an IAM Role as a profile in the AWS CLI and it will automatically assume the role for you. Here is an example from Using an IAM role in the AWS CLI - AWS Command Line Interface: [profile marketingadmin] role_arn = arn:aws:iam::123456789012:role/marketingadminrole source_profile = user1 This is saying: If a user specifies --profile marketingadmin Then use the credentials of profile user1 To call AssumeRole on the specified role This means you can simply call a command like this and

Can I Get Free PS+ Games 'retroactively'?

Answer : Unfortunately, there is no way to retroactively redeem past PS Plus games. If you haven't redeemed those games when they were free, you'll have to either purchase them or wait until they're offered for free once more. To redeem a PS Plus game, simply "purchase" it while it is still free. You don't need to actually download the game. You cannot claim free games from past months. For instance, it's April now, meaning if I didn't visit the store and download Bloodborne through PS+ last month then I can't go back and do so now, even if my subscription is still active. However, if you already claimed a free game in the month it was offered, then wait a few months and remove it from your system, you can go back and re-download it for free as long as you're still subscribed to PS+

C# How To Use WM_GETTEXT / GetWindowText API / Window Title

Answer : public class GetTextTestClass{ [System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint = "SendMessage", CharSet = System.Runtime.InteropServices.CharSet.Auto)] public static extern bool SendMessage(IntPtr hWnd, uint Msg, int wParam, StringBuilder lParam); [System.Runtime.InteropServices.DllImport("user32.dll", SetLastError = true)] public static extern IntPtr SendMessage(int hWnd, int Msg, int wparam, int lparam); const int WM_GETTEXT = 0x000D; const int WM_GETTEXTLENGTH = 0x000E; public string GetControlText(IntPtr hWnd){ // Get the size of the string required to hold the window title (including trailing null.) Int32 titleSize = SendMessage((int)hWnd, WM_GETTEXTLENGTH, 0, 0).ToInt32(); // If titleSize is 0, there is no title so return an empty string (or null) if (titleSize == 0) return String.Empty; StringBuilder title = new StringBuilder(

Bottom Borders On WPF Grid

Answer : On a Border control You can do BorderThickness="0 0 0 1" to only have a bottom border shown. Top and bottom border thickness of 5, left and right border thickness of 0 BorderThickness="0 5" Top and bottom border thickness of 0, left and right border thickness of 5 BorderThickness="5 0" Border Thickness - Left: 1, Top: 2, Right:3, Bottom: 4 BorderThickness="1 2 3 4" Hope this helps!

Bash: Yum: Command Not Found Code Example

Example: sudo: yum: command not found After simple checks I've asked you in answer comment: [root@Backup yum.repos.d]# yum -bash: yum: command not found [root@Backup yum.repos.d]# which yum /usr/bin/which: no yum in (/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin) [root@Backup yum.repos.d]# echo $PATH /usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin [root@Backup yum.repos.d]# rpm -q yum package yum is not installed we can verify that you don't have yum installed in your system. Please install it via rpm and you'll be able to launch it.

Never Gonna Let You Down Rick Astley Lyrics Code Example

Example 1: never gonna give you up lyrics /* We're no strangers to love You know the rules and so do I A full commitment's what I'm thinking of You wouldn't get this from any other guy I just wanna tell you how I'm feeling Gotta make you understand Never gonna give you up Never gonna let you down Never gonna run around and desert you Never gonna make you cry Never gonna say goodbye Never gonna tell a lie and hurt you We've known each other for so long Your heart's been aching but you're too shy to say it Inside we both know what's been going on We know the game and we're gonna play it And if you ask me how I'm feeling Don't tell me you're too blind to see Never gonna give you up Never gonna let you down Never gonna run around and desert you Never gonna make you cry Never gonna say goodbye Never gonna tell a lie and hurt you Never gonna give you up Never gonna let you down Never gonna run around a

12 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

Clear Composer Cache Code Example

Example 1: clear composer cache composer clearcache //Then autoload composer composer dump-autoload Example 2: composer remove cache composer clearcache #You can also use composer clear-cache #which is an alias for clearcache. Example 3: composer clear cache $ composer clearcache Example 4: clear cache without using composer in laravel 8 Route::get('/clear-cache', function() { $exitCode = Artisan::call('cache:clear'); // return what you want });

Add Inventory Icon Font Awesome Code Example

Example: add icon font awesome < i class = " fa fa-plus " aria-hidden = " true " > </ i >

Can't Install Android Emulator For AMD Processors

Answer : I found the answer after long time. I had to enable Virtualization on my machine. If you are using Avast antivirus (Or AVG), The problem may be in it. So things to do to fix this: -Activate Virtualization in bios -Deactivate Hyper-v and hypervisor platform in "activate/desactivate windows function" & run powershell as admin and make :"Disable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V" -In Avast Antivirus. In settings click Troubleshoot on the left side of the screen, uncheck the box next to Enable hardware assisted virtualization, then click OK to confirm and restart your computer I've got the solution from https://github.com/google/android-emulator-hypervisor-driver-for-amd-processors/issues/10#issuecomment-715423881 If You are using AMD Ryzen Just go to bios setting check for SVM Mode if it is Disabled then Enable it .. Emulator work perfectly..Below Link show where to enable SVM Mode in Aorus Gigabyte Motherboard BIO

Can Zuul Edge Server Be Used Without Eureka / Ribbon

Answer : Yes, it is totally possible.You have to use @EnableZuulProxy on your config class and config it something like this : zuul: routes: yourService: path: /yourService/** serviceId: yourService ribbon: eureka: enabled: false yourService: ribbon: listOfServers: localhost:8080 A sample usage can be like this: shared.microservice.customer.service1.url=zttp://127.0.0.1:8080/shared/microservice/customer/ shared.microservice.customer.service2.url=zttp://127.0.0.1:8181/shared/microservice/customer/ ribbon.eureka.enabled = false zuul.routes.customer-micro-service.path: /shared/microservice/customer/** zuul.routes.customer-micro-service.serviceId: customers customers.ribbon.listOfServers = zttp://ip:port1/shared/microservice/customer/,zttp://ip2:port2/shared/microservice/customer/

10001 Binary To Decimal Code Example

Example 1: binary to decimal double binaryToDecimal ( char binary [ DIM ] ) { char binary2 [ DIM ] = "" , floa [ DIM ] = "" ; double decimal = 0 , negDec = 0 , flo = 0 ; int count = 0 , j = 0 , i = 0 , f = 0 , g = 0 , h = 0 , count1 = 0 , d = 0 , k = 0 ; while ( binary [ d ] != '\0' & & binary [ d ] != '.' ) { d + + ; } d - - ; if ( binary [ 0 ] == '-' ) { while ( binary [ k ] != '\0' ) { binary [ k ] = binary [ k + 1 ] ; k + + ; } k = 0 ; while ( binary [ k ] == '0' ) { d - - ; k + + ; } negDec = pot ( 2.000 , d * 1.000 , 1 ) ; } while ( binary [ i ] != '\0' & & binary [ i ] != '.' ) { i + + ; } i - - ; count = i ; h = i ; while ( binary [ h ] != '\0' ) { floa [ g ] = binary [ h + 2 ] ; g + + ; h + + ; } g - - ; count1 = g

Attempting To Recover Windows 7 On My Toshiba Laptop

Answer : When you run Netbootin, it will ask for the distribution that you want to put on the USB, or the ISO itself. In the distribution list, select Ubuntu (either 32 or 64 bit, no, it does not have to be ubuntu, but its just my preference), and download it. Make sure the right drive is selected (the USB that you want to write the data to after the data has been written, shut down your computer, insert the USB, and when you restart, I believe you hit F12 to get to the boot order. Select the USB Follow the ubuntu setup, its pretty straightforward, dont parition anything, just run it as a Live CD (it might be called a live USB, not sure) When you are done with the 'install' See if you can see any of the files on the hard drive, or if Gparted can see the hard drive. If the answer is yes, your HD is probably fine. If not, its probably busted. Please comment back here if there are any issues. The unit has a recovery partition, pretty much all laptops sold now have a r

Numpy Array Length Code Example

Example 1: code for dimensions in numpy import numpy as np arr = np . array ( [ 1 , 2 , 3 , 4 ] ) arr_2D = np . array ( [ [ 1 , 2 , 3 , 4 , 5 ] , [ 6 , 7 , 8 , 9 , 10 ] ] ) print ( arr . ndim ) print ( arr_2D . ndim ) Example 2: numpy array length np_array . size Example 3: python numpy array size of n numpy . array ( [ 0 ] * n ) #creates an int64 numpy array of size n with each element having a vaule of 0 numpy . array ( [ 0 ] * n , dtype = '<type>' ) #creates a numpy array of size n with a type of < type > Example 4: numpy how to length of vector >> > x = np . zeros ( ( 3 , 5 , 2 ) , dtype = np . complex128 ) >> > x . size 30 >> > np . prod ( x . shape ) 30 Example 5: numpy number of elements import numpy as np x = np . array ( [ 1 , 2 , 3 ] , dtype = np . float64 ) print ( "Size of the array: " , x . size ) print ( "Length of one array element in bytes: " , x .

Are There Any Keyboard Shortcuts To Shutdown?

Answer : No, but assuming you're using 11.10, one can easily be added by going to: System Settings Keyboard Shortcuts tab Custom Shortcuts Then the little + icon. You can give it the name "Shutdown", and the command. Try the command below: gnome-session-quit --power-off --force , then apply whatever keyboard shortcut you want to it. Yes there is shortcut to shutdown (not a keyboard one) . Shortly pressing and releasing the power button will call the shutdown dialogue box. You can try this steps as well: Press Alt + F10 . The file menu will get displayed in the top. Use the Right Arrow key in your keyboad and go to extreme right (Pressing Left Arrow might also work and be much faster). Select the shutdown in from the menu and hit enter.

Android Toast Duration Code Example

Example: android studio Toast usage Context context = getApplicationContext(); CharSequence text = "Hello toast!"; int duration = Toast.LENGTH_SHORT; Toast toast = Toast.makeText(context, text, duration); toast.show();

Android - Can I Restart Bluetooth From The Terminal?

Answer : The following terminal command should enable Bluetooth via adb shell or Terminal Emulator app: su am start -a android.bluetooth.adapter.action.REQUEST_ENABLE On most versions of Android, this command will present a pop-up window to the user asking to confirm request to enable BT. I believe this was done for security purposes whenever an app that is not system is toggling BT. I haven't found a way to disable BT via a shell command unfortunately. With WiFi it's a lot easier, and does not prompt user for permission: su svc wifi enable will turn it on, and su svc wifi disable will turn it off. in android.bluetooth.IBluetoothManager, there some parameters TRANSACTION_registerAdapter = (android.os.IBinder.FIRST_CALL_TRANSACTION + 0); TRANSACTION_unregisterAdapter = (android.os.IBinder.FIRST_CALL_TRANSACTION + 1); TRANSACTION_registerStateChangeCallback = (android.os.IBinder.FIRST_CALL_TRANSACTION + 2); TRANSACTION_unregisterStateChangeCallback

Among Us Font Css Code Example

Example: font-family css font-family : "Times New Roman" , Georgia , serif ; /* If the browser does not support the first font (ie: Times New Roman), it will then try the next font (ie: Georgia). The last font should always be a "generic-family" font (ie: serif, sans-serif, etc..). /* If font is more then one word, it must be put into quotes. */

Bangalore To Darbhanga Flight Code Example

Example 1: bombay to darbhanga flight 1 flight per day, 2h 30m duration Example 2: darbhanga bangalore flight Flights from Darbhanga (DBR) to Bengaluru (BLR) at Evening

Get The Size Of An Array Python Code Example

Example 1: size array python size = len ( myList ) Example 2: python get array length # To get the length of a Python array , use 'len()' a = arr . array ( ‘d’ , [ 1.1 , 2.1 , 3.1 ] ) len ( a ) # Output : 3

Angular 9 How To Use Injection Server Inside Another Server Code Example

Example: how to inject service in component angular 6 you can inject service in components constructor: constructor(public anyService: Service){}