Posts

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" />