Posts

Showing posts from May, 2013

Apple - Can I Manually Limit The %CPU Used By A Process?

Answer : cputhrottle is the tool you need. You can install it with Homebrew. You can monitor a series of processes by name by running the Bash script below. I'm not quite sure how to turn this into a login item since cputhrottle requires superuser permissions. Run it as a script, in an Automator workflow, whatever: # Get the Process/App names from Activity Monitor and put them here apps=("AppOne" "AppTwo" "AppThree") # Set the respective limits here limits={30 40 50) while true; do for app in ${apps}; do for limit in ${limits}; do for pid in $(pgrep ${app}); do sudo /path/to/cputhrottle ${pid} ${limit} done done done done [Edited] I've added a different version for this script (a bash script), which might be useful for people looking for limiting the CPU for multiple applications. This new script also allows you to specify a list containing the application name and the CPU limit for it. The main di

Angular New Date Format Code Example

Example 1: angular date formats 'short' : equivalent to 'M/d/yy, h:mm a' ( 6 / 15 / 15 , 9 : 03 AM ) . 'medium' : equivalent to 'MMM d, y, h:mm:ss a' ( Jun 15 , 2015 , 9 : 03 : 01 AM ) . 'long' : equivalent to 'MMMM d, y, h:mm:ss a z' ( June 15 , 2015 at 9 : 03 : 01 AM GMT + 1 ) . 'full' : equivalent to 'EEEE, MMMM d, y, h:mm:ss a zzzz' ( Monday , June 15 , 2015 at 9 : 03 : 01 AM GMT + 01 : 00 ) . 'shortDate' : equivalent to 'M/d/yy' ( 6 / 15 / 15 ) . 'mediumDate' : equivalent to 'MMM d, y' ( Jun 15 , 2015 ) . 'longDate' : equivalent to 'MMMM d, y' ( June 15 , 2015 ) . 'fullDate' : equivalent to 'EEEE, MMMM d, y' ( Monday , June 15 , 2015 ) . 'shortTime' : equivalent to 'h:mm a' ( 9 : 03 AM ) . 'mediumTime' : equivalent to 'h:mm:ss a' ( 9 : 03 : 01 AM ) . 'longTime' :

How To Make Border Shadow In Css Code Example

Example 1: css box shadow #example1 { box-shadow : 10 px 10 px 8 px #888888 ; } Example 2: box-shadow css /* Keyword values */ box-shadow : none ; /* offset-x | offset-y | color */ box-shadow : 60 px -16 px teal ; /* offset-x | offset-y | blur-radius | color */ box-shadow : 10 px 5 px 5 px black ; /* offset-x | offset-y | blur-radius | spread-radius | color */ box-shadow : 2 px 2 px 2 px 1 px rgba ( 0 , 0 , 0 , 0.2 ) ; /* inset | offset-x | offset-y | color */ box-shadow : inset 5 em 1 em gold ; /* Any number of shadows, separated by commas */ box-shadow : 3 px 3 px red , -1 em 0 0.4 em olive ; /* Global keywords */ box-shadow : inherit ; box-shadow : initial ; box-shadow : unset ; Example 3: border shadow css #example1 { box-shadow : 5 px 10 px ; }

Simple Custom Checkbox Codepen Code Example

Example: custom checkbox button codepen pure css <h1 class= "title" >Pure CSS Custom Checkboxes</h1> go to source

Youtube 2 Mp3 Converter Code Example

Example: yt to mp3 Youtube - DL works great . Download from https : //youtube-dl.org/. To use, type youtube-dl <url> --audio-format mp3

Cses Problem Set Coin Combinations I Code Example

Example: coin combinations 1 cses solution #include <bits/stdc++.h>using namespace std;using ll = long long;using vi = vector < int > ;#define pb push_back#define rsz resize#define all(x) begin(x), end(x)#define sz(x) (int)(x).size()using pi = pair < int,int > ;#define f first#define s second#define mp make_pairvoid setIO(string name = "") { // name is nonempty for USACO file I/O ios_base::sync_with_stdio(0); cin.tie(0); // see Fast Input & Output if(sz(name)){ freopen((name+".in").c_str(), "r", stdin); // see Input & Output freopen((name+".out").c_str(), "w", stdout); }} ll dp[1000001]; const int MOD = (int) 1e9 + 7; int main(){ int n, x; cin >> n >> x; vi coins(n); for (int i = 0; i < n; i++) { cin >> coins[i]; } dp[0] = 1; for (int weight = 0; weight <= x; weight++) { for (int i = 1; i <= n; i++) { if(weight - coi

Bootstrap With JQuery Validation Plugin

Image
Answer : for total compatibility with twitter bootstrap 3, I need to override some plugins methods: // override jquery validate plugin defaults $.validator.setDefaults({ highlight: function(element) { $(element).closest('.form-group').addClass('has-error'); }, unhighlight: function(element) { $(element).closest('.form-group').removeClass('has-error'); }, errorElement: 'span', errorClass: 'help-block', errorPlacement: function(error, element) { if(element.parent('.input-group').length) { error.insertAfter(element.parent()); } else { error.insertAfter(element); } } }); See Example: http://jsfiddle.net/mapb_1990/hTPY7/7/ For full compatibility with Bootstrap 3 I added support for input-group , radio and checkbox , that was missing in the other solutions. Update 10/20/2017 : Inspected suggestions of the other answers and added ad

Code Checker Online C++ 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

Ruby On Rails Cheatsheet Code Example

Example: ruby cheat sheet Four good ruby cheat Sheets : https : //overapi.com/ruby http : //www.testingeducation.org/conference/wtst3_pettichord9.pdf https : //github.com/ThibaultJanBeyer/cheatsheets/blob/master/Ruby-Cheatsheet.md#basics https : //www.vikingcodeschool.com/professional-development-with-ruby/ruby-cheat-sheet

Android How To Create Intent Filter For Custom File Extension That Does NOT Make It Part Of A Chooser For Everything On The Phone

Answer : The only way to solve this problem is add scheme and host attributes to your intent filter: <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <data android:scheme="file" /> <data android:mimeType="*/*" /> <data android:pathPattern=".*\\.tgtp" /> <data android:host="*" /> </intent-filter> That is because in documentation says that android:pathPattern only works if has an scheme and host defined. http://developer.android.com/guide/topics/manifest/data-element.html Hope it helps. I've been struggling with this quite a bit for a custom file extension, myself. After a lot of searching, I found this web page where the poster discovered that Android's patternMatcher class (which is used for the pathPattern matching in Intent-Filters) has unexpected behavior when y

How To Write A Delay Function In C Code Example

Example: C delay /** really not much to say... just a way to program a delay between commands in your code. **/ //C library statement # include <time.h> //Driver program void dealy ( int numOfSec ) { /* the delay itself runs with milli seconds so here we multiply the seconds by 1000. */ int numOfMilliSec = 1000 * numOfSec ; /* Making the time pass with nothing running until the time is up. */ time_t startTime = clock ( ) ; while ( clock ( ) < startTime + numOfMilliSec ) ; } /*To use the delay just use the command: delay(x); you need to replace x with the number of seconds that you want the delay to be. */ ///The code itself without the details: # include <time.h> void delay ( int numOfSec ) { int numOfMilliSec = 1000 * numOfSec ; time_t startTime = clock ( ) ; while ( clock ( ) < startTime + numOfMilliSec ) ; }

Angular RouterOutlet Example

directive Acts as a placeholder that Angular dynamically fills based on the current router state. See more... See also Routing tutorial. RouterLink Route Exported from RouterModule Selectors router-outlet Properties Property Description @ Output('activate') activateEvents : EventEmitter<any> @ Output('deactivate') deactivateEvents : EventEmitter<any> isActivated : boolean Read-Only component : Object Read-Only activatedRoute : ActivatedRoute Read-Only activatedRouteData : Data Read-Only Template variable references Identifier Usage outlet #myTemplateVar="outlet" Description Each outlet can have a unique name, determined by the optional name attribute. The name cannot be set or changed dynamically. If not set, default value is "primary". <router-outlet></router-outlet> <router-outlet name='left'></router

Map Function In Arduino With Example

Example 1: map arduino Syntax map ( value , fromLow , fromHigh , toLow , toHigh ) Parameters value : the number to map . fromLow : the lower bound of the value’s current range . fromHigh : the upper bound of the value’s current range . toLow : the lower bound of the value’s target range . toHigh : the upper bound of the value’s target range . Example : map ( val , 0 , 255 , 0 , 1023 ) ; Example 2: arduino map function long map ( long x , long in_min , long in_max , long out_min , long out_max ) { return ( x - in_min ) * ( out_max - out_min ) / ( in_max - in_min ) + out_min ; }

Border Radius Only Top Left Flutter Code Example

Example 1: flutter container rounded corners Container( decoration: BoxDecoration( border: Border.all( color: Colors.red[500], ), borderRadius: BorderRadius.all(Radius.circular(20)) ), child: ... ) Example 2: flutter container border radius only left borderRadius: BorderRadius.only( topRight: Radius.circular(10.0), bottomRight: Radius.circular(10.0)), Example 3: column round border flutter Container( decoration: BoxDecoration( border: Border.all( color: Colors.red[500], ), color: Colors.green[500], borderRadius: BorderRadius.all(Radius.circular(20)) ), child: ... )

Flutter Datetime Format | Code Example

Example 1: flutter datetime format import 'package : intl / intl . dart' ; DateTime now = DateTime . now ( ) ; String formattedDate = DateFormat ( 'yyyy - MM - dd – kk : mm' ) . format ( now ) ; Example 2: flutter dateFormat import 'package : intl / intl . dart' ;

Skeleton Cdn Css Code Example

Example 1: skeleton css cdn <link rel= "stylesheet" href= "https://cdnjs.cloudflare.com/ajax/libs/skeleton/2.0.4/skeleton.min.css" > Example 2: skeleton cdn <link rel= "stylesheet" href= "https://cdnjs.cloudflare.com/ajax/libs/skeleton/2.0.4/skeleton.css" integrity= "sha512-5fsy+3xG8N/1PV5MIJz9ZsWpkltijBI48gBzQ/Z2eVATePGHOkMIn+xTDHIfTZFVb9GMpflF2wOWItqxAP2oLQ==" crossorigin= "anonymous" />

Display None Class In Bootstrap 4 Code Example

Example 1: display sm none Hidden on all .d-none Hidden only on xs .d-none .d-sm-block Hidden only on sm .d-sm-none .d-md-block Hidden only on md .d-md-none .d-lg-block Hidden only on lg .d-lg-none .d-xl-block Hidden only on xl .d-xl-none Visible on all .d-block Visible only on xs .d-block .d-sm-none Visible only on sm .d-none .d-sm-block .d-md-none Visible only on md .d-none .d-md-block .d-lg-none Visible only on lg .d-none .d-lg-block .d-xl-none Visible only on xl .d-none .d-xl-block Example 2: bootstrap display inline block <div class= "d-inline-block" ></div> Example 3: bootstrap display none <!-- Bootstrap 4 --> <div class= "d-none" ></div> <!-- Bootstrap 3 --> <!-- <div class= "hidden- { screen size } "></div> --> <div class= "hidden-md" ></div> Example 4: is display-block a class <span class= "d-block p-2 bg-primary text-white" >d-block</span> <

C# - Capturing The Mouse Cursor Image

Image
Answer : While I can't explain exactly why this happens, I think I can show how to get around it. The ICONINFO struct contains two members, hbmMask and hbmColor, that contain the mask and color bitmaps, respectively, for the cursor (see the MSDN page for ICONINFO for the official documentation). When you call GetIconInfo() for the default cursor, the ICONINFO struct contains both valid mask and color bitmaps, as shown below (Note: the red border has been added to clearly show the image boundaries): Default Cursor Mask Bitmap Default Cursor Color Bitmap When Windows draws the default cursor, the mask bitmap is first applied with an AND raster operation, then the color bitmap is applied with an XOR raster operation. This results in an opaque cursor and a transparent background. When you call GetIconInfo() for the I-Beam cursor, though, the ICONINFO struct only contains a valid mask bitmap, and no color bitmap, as shown below (Note: again, the red border has been adde

Can You Use Canvas.getContext('3d')? If Yes, How?

Answer : There is a 3D context for canvas, but it is not called "3d", but WebGL ("webgl"). WebGL should be available in the most up-to-date versions of all browsers. Use: <!DOCTYPE html> <html> <body> <canvas id='c'></canvas> <script> var c = document.getElementById('c'); var gl = c.getContext('webgl') || c.getContext("experimental-webgl"); gl.clearColor(0,0,0.8,1); gl.clear(gl.COLOR_BUFFER_BIT); </script> </body> </html> how could you use that? I tried 3D before, but didn't really understand if you think "real" languages are difficult, you will have a lot of trouble with WebGL. In some respects it is quite high level, in other respects it is quite low level. You should brush up on your maths(geometry) and prepare for some hard work. three.js is a very appreciated library that allows you to do yet a lot of 3d without dealing wit

Css Wavy Line Animation Code Example

Example 1: css wavy line svg { background : url ( 'https://farm9.staticflickr.com/8461/8048823381_0fbc2d8efb.jpg' ) no-repeat center center ; background-size : cover ; width : 10 % ; display : block ; } Example 2: css wavy line svg { background : url ( 'https://farm9.staticflickr.com/8461/8048823381_0fbc2d8efb.jpg' ) no-repeat center center ; background-size : cover ; width : 1 % ; display : block ; }

Youtube Mp3 Playlist Downloader Code Example

Example: youtube dl download playlist mp3 youtube - dl -- extract - audio -- audio - format mp3 - o "%(title)s.%(ext)s" < url to playlist >

Could Not Resolve Com.android.tools.build:gradle:2.2.3

Answer : It turns out the solution to my particular issue was relatively simple. The error message was a bit deceiving as this was not a problem with the offline mode switch, but rather confusion with the gradle file. Here are a few steps I took to fix the issue: For Android Studio 2.3 go to File>Settings>Gradle and select the "Use default gradle wrapper" option. Also make sure the checkbox next to "Offline work" is unchecked just in case. Click the "Apply" button Within the build. gradle file (the one named after your project) under the "Gradle Scripts" section of Android Studio make certain that your current build gradle class path matches the current version of Android Studio. An example for Android Studio 2.3: buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:2.3.0' } } Also within the Gradle Scripts section make sure that your gradle-wrapper.properti

26 Out Of 30 Percentage Code Example

Example: what percent is 27 out of 30 oh so you have found me. I am the secret commenter. goodbye now

Create Alias For Shell Script Code Example

Example 1: how to add alias in linux alias l = "ls -al" Example 2: linux add alias # syntax # alias *<alias-name>="*<what-alias-represents>" # example alias ll = "ls -lrt"

Flexbox 3 Columns Code Example

Example 1: flexbox grid .container { max-width : 1335 px ; margin : 0 auto ; } .grid-row { display : flex ; flex-flow : row wrap ; justify-content : flex-start ; } .grid-item { height : 550 px ; /*optional*/ flex-basis : 20 % ; /* initial percantage */ -ms-flex : auto ; width : 259 px ; /*optional*/ position : relative ; padding : 10 px ; /*optional*/ box-sizing : border-box ; } @media ( max-width : 1333 px ) { /*xl*/ .grid-item { flex-basis : 33.33 % ; } } @media ( max-width : 1073 px ) { /*lg*/ .grid-item { flex-basis : 33.33 % ; } } @media ( max-width : 815 px ) { /*md*/ .grid-item { flex-basis : 50 % ; } } @media ( max-width : 555 px ) { /*sm*/ .grid-item { flex-basis : 100 % ; } } Example 2: flex grid 3 columns <div class= "row around-xs" > <div class= "col-xs-2" > <div class= "box" >

Bulma Button Error Code Example

Example: submit button bulma < div class = " field is-grouped is-grouped-centered " > < p class = " control " > < a class = " button is-primary " > Submit </ a > </ p > </ div >
Answer : For some reason that i do not understand , this combination of build versions made the issue : grade version = 4.10.1 classpath 'com.android.tools.build:gradle:3.4.0-alpha01' when i switched to these build versions : grade version = 4.6 classpath 'com.android.tools.build:gradle:3.2.1' The issue was solved ! File -> Close project Open an existing Android Studio Project Open you project Hope it will work. sometimes, R file is not generated because of package name on android manifest is not match with package module that you have.

Glow Text Generator Css Code Example

Example: css glow text .glow { font-size : 80 px ; color : #fff ; text-align : center ; -webkit-animation : glow 1 s ease-in-out infinite alternate ; -moz-animation : glow 1 s ease-in-out infinite alternate ; animation : glow 1 s ease-in-out infinite alternate ; } @-webkit-keyframes glow { from { text-shadow : 0 0 10 px #fff , 0 0 20 px #fff , 0 0 30 px #e60073 , 0 0 40 px #e60073 , 0 0 50 px #e60073 , 0 0 60 px #e60073 , 0 0 70 px #e60073 ; } to { text-shadow : 0 0 20 px #fff , 0 0 30 px #ff4da6 , 0 0 40 px #ff4da6 , 0 0 50 px #ff4da6 , 0 0 60 px #ff4da6 , 0 0 70 px #ff4da6 , 0 0 80 px #ff4da6 ; } } </style> use/call the class <h1 class= "glow" >GLOWING TEXT</h1>

Compile Java To Class Online Code Example

Example: online java compiler Repl . it Compiler : click source buttton to go to the website Pros : You can add files , do javafx and jswing .

Add Build Parameter In Jenkins Build Schedule

Answer : Basically, with the 'Build periodically' option you can't schedule a Jenkins job with parameters. However, to schedule a job at different times that needs to use different environments, you have to use the parameterized-scheduler plugin or search for it in (Manage Jenkins -> Manage Plugins -> Parameterized Scheduler). Examples: # Parameter1 H/15 * * * * %Parameter1 # Parameter2 H/30 * * * * %Parameter2 Remember you have to have your parameters already setup because the plugin is visible only for jobs with parameters. The Node and Label parameter plugin can help since it allows you to select individual nodes assuming your different servers qa1 and qa2 are already configured. Hope that clarifies things for you. With the native Jenkins crontab, it's not possible. But it should be possible with this plugin: https://github.com/jwmach1/parameterized-scheduler You have to fork the repo and build this plugin + do a manual installation. Th

Bundle Install Is Not Working

Answer : Open the Gemfile and change first line from this source 'https://www.rubygems.org' to this source 'http://www.rubygems.org' remove the ' s ' from ' https '. As @Wasif mentioned, first make sure the Ruby Gems site is up and your network access is ok. If they works fine, try it like this: First, delete your Gemfile.lock file Then run gem update --system Then in your Gemfile try changing the first line source 'https://rubygems.org' to http:// (without an s ) Unless there is a problem with your connectivity this should fix the issue with bundle install .